Hi,
I need use GetTextExtent and I don't understant why GetTextExtent always return the same value if I change some values of the selected font. This is my example:
Why I get always the value 24 when I call GetTextExtent if I change the font size?
Thank you very much.
I need use GetTextExtent and I don't understant why GetTextExtent always return the same value if I change some values of the selected font. This is my example:
Code:
LOGFONT lf;
pOldFont->GetLogFont(&lf);
CString sExampleSizeByChar;
sExampleSizeByChar = _T("hello");
DWORD dwPixelsByChar = dc.GetTextExtent(sExampleSizeByChar).cx / 1.15;
// I change the font size
lf.lfHeight = lf.lfHeight + 10;
lf.lfWidth = lf.lfWidth + 10;
CFont* pFont = new CFont;
pFont->CreateFontIndirect(&lf);
dc.SelectObject(pFont);
dwPixelsByChar = dc.GetTextExtent(sExampleSizeByChar).cx / 1.15;
Thank you very much.