I want to get the exact height of the text in Windows I call DrawText with both GetTextExtentPoint32 and DT_CALCRECT flag and the same Give results.
It seems that the height is based on the full cell height regardless of the actual text returned, be ready.
The code below is a WM_PAINT handler for the standard Visual Studio 2013 Win32 project. It creates a large font and pulls the sample text. The highest part of the text is 98 pixels, but the value of GetTextExtentPoint32 is 131.
I think that some applications can be full cell like height, but also some applications (like me) just want Used by real height text
Anyone can scan down to even find out how to get information out
Yes, I render a memory DC and the first non-background color pixels - but that is super slow going
Thank you
case WM_PAINT: {hdc = initial paint (Acdblyuend, and PS); HFONT hfont = CreateFont (-99, 0, 0, 0, FW_NORMAL, wrong, wrong, wrong, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, L "Segoe UI SemiBold"); Auto Old_font = Selection Object (HDC, HFF); Wchar_t sample_text [] = L "123 123"; Size_t sample_text_length = wcslen (sample_text); Size S; GetTextExtentPoint32 (hdc, sample_text, sample_text_length, & amp;); RECT R = {10, 10, 10 + s.cx, 10 + s.cy}; Setbacklor (HDC, RGB (80, 120, 160)); SetTextColor (HDC, RGB (220, 220, 220)); DrawText (hdc, sample_text, sample_text_length, & amp; r, DT_SINGLELINE | DT_NOPREFIX | DT_LEFT | DT_TOP); SelectObject (hdc, old_hfont); DeleteObject (hfont); Endpents (hwnd, and ps); break; }
back
No comments:
Post a Comment