Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3027

GetTextExtent don't detect the font size

$
0
0
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:

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;

Why I get always the value 24 when I call GetTextExtent if I change the font size?

Thank you very much.

Viewing all articles
Browse latest Browse all 3027

Trending Articles