|
-
Oct 8th, 2001, 02:49 PM
#1
Thread Starter
Addicted Member
DrawText - DT_CALCRECT
I'm using DrawText to output some text (duh!) to a PictureBox. But first, I call it using DT_CALCRECT so I can know the dimension of the text so I can center it, but this does not work very well, because for example, DrawText returns 13 as the height, but if I manually measure the height of the text in MSPaint, the height is 11.
BTW, I must center the text manually, i.e., without using centering parameters in DrawText.
Thanks in advance.
-
Oct 8th, 2001, 03:29 PM
#2
Thread Starter
Addicted Member
I found the cause...
It appears Windows adds those extra pixels as the size letters like p, q, have below the "margin" line. So, now I'd need to know what that extra size is for a given font... Is this possible?
-
Oct 8th, 2001, 08:32 PM
#3
Fanatic Member
You can use GetTextMetrics() on the DC to get that value. The TEXTMETRIC struct will be filled with the info of the DC's font, and the particular thing you're asking about, the height below the line, is given by the tmDescent member. tmAscent is the height above the line, and tmHeight is the sum of those two.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Oct 9th, 2001, 12:28 PM
#4
Thread Starter
Addicted Member
That's what I was looking for! Thanks a lot.
Live your own life, for you will die your own death.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|