Link to home
Start Free TrialLog in
Avatar of Knut Hunstad
Knut HunstadFlag for Norway

asked on

Drawtext

Hi!

What precisely should Drawtext with DT_CALCRECT return? Specifications say that it returns the rectangle needed for the text, but it doesn't!

I have a fixed width font where I run DrawText/DT_CALCRECT for both the string "9" and the string "99". They return a width of 9 and 18. By drawing vertical lines I can clearly see that I need to add 7 to move a vertical line one character and 14 to move it 2 characters. So why does Drawtext return 9??? GetTextExtent and GetTextMetrics all return 9 for the character width as well.

I run this from within a routine that is called during drawing of a control, so the DC has the correct font selected already (I think).

Thanks for any help!

P.S.: This is a simplified version of my question https://www.experts-exchange.com/questions/28317440/DrawText-vs-GetCellRect.html, since I got no response to that so far.
Avatar of Knut Hunstad
Knut Hunstad
Flag of Norway image

ASKER

Oh, yes, I forgot: the space needed for the text "9" is actually only 6 and for "99" it's 13, since there is a space between each character...
ASKER CERTIFIED SOLUTION
Avatar of Knut Hunstad
Knut Hunstad
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial