Can you measure the width of a string more exactly in WIN32 than using the GetTextMetrics function and using tmAveCharWidth*strSize?
A:
Kirill V. Lyadvinsky
2009-07-14 17:08:06
+6
A:
Try using GetTextExtentPoint32. That uses the current font for the given device context to measure the width and height of the rendered string in pixels.
Nick Meyer
2009-07-14 17:09:21
Thanks, this is what i was lokking for. :)
Razvi
2009-07-14 17:38:28
+1
A:
Depending on how you are using this, you can use DrawText with DT_CALCRECT specified and it will (its always done it fairly accurately for me) calculate the size of the required rectangle based on the text/font/etc.
DeusAduro
2009-07-14 17:10:46
+4
A:
I don't know for certain, but it seems that:
RECT r = { 0, 0, 0, 0 };
char str[] = "Whatever";
DrawText(hDC, str, strlen(str), &r, DT_CALCRECT);
might work.
Evan Teran
2009-07-14 17:11:18