Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DrawText and DT_CALCRECT

167 views
Skip to first unread message

Chris Harper

unread,
Apr 17, 1999, 3:00:00 AM4/17/99
to
Can someone please tell me why two subsequent calls to DrawText, one with
DT_CALCRECT and the other without, results in the height calculation being
different? In the code below, the first call to DrawText uses DT_CALCRECT.
The DrawText returns the height of the calculated rect, which does match the
rect it calculated. But the second call to DrawText with the exact same
arguments without the use of DT_CALCRECT, results in the height of the
actual drawn text to be greater than what was calculated in the first call.
The second call to DrawText returns the height that is greater than the
first call. The text drawn to the DC has a height that matches the height
returned from the second call. Because of this, I have no way to calculate
the height of the text with actually drawing it. This only seems to happen
after the text reaches a particular height, like over 150 units, or
something.

nFmt = DT_END_ELLIPSIS | DT_EXPANDTABS | DT_NOCLIP | DT_WORDBREAK |
DT_CALCRECT;
nHt1 = DrawText(hDC, strText, &rectItem, nFmt);

nFmt = DT_END_ELLIPSIS | DT_EXPANDTABS | DT_NOCLIP | DT_WORDBREAK;
nHt2 = DrawText(hDC, strText, &rectItem, nFmt);

_ASSERT(nHt1 == nHt2);


Any help is very appreciated.


Mike Enright

unread,
Apr 19, 1999, 3:00:00 AM4/19/99
to
"Chris Harper" <harpe...@earthlink.net> wrote:

>Can someone please tell me why two subsequent calls to DrawText, one with
>DT_CALCRECT and the other without, results in the height calculation being
>different?

I can't tell you why, but if you look here:

http://msdn.microsoft.com/library/sdkdoc/gdi/fontext_0odw.htm

you'll see that DT_EXPANDTABS | DT_END_ELLIPSIS is not supported.


>
>nFmt = DT_END_ELLIPSIS | DT_EXPANDTABS | DT_NOCLIP | DT_WORDBREAK |
>DT_CALCRECT;
>nHt1 = DrawText(hDC, strText, &rectItem, nFmt);
>


--
Mike Enright
enri...@acm.org (Email replies cheerfully ignored, use the news group)
http://www.users.cts.com/sd/m/menright/
Cardiff-by-the-Sea, California, USA


Jamie

unread,
May 2, 1999, 3:00:00 AM5/2/99
to
Hi, i recall a problem like this. I ended up using DrawTextEx and then
wetn straight to the RTF Control. I think it miught have something to
do with line spacing or something like that.

Hope this helps a bit!
Jamie O'Brien
jam...@interworx.com.au


0 new messages