Ich muss die Breite einer Zeichenfolge mit beliebiger Schriftart finden. Wenn ich jedoch GetTextExtentPoint32
verwende, wird die aktuelle Schriftart nicht berücksichtigt. Das ist mein Code:GetTextExtentPoint32 berücksichtigt nicht die aktuelle Schriftart
HFONT hFont = CreateFont(36, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL);
SelectObject(GetDC(m_hSettingsWnd), hFont);
GetTextExtentPoint32(GetDC(m_hSettingsWnd), TITLE_TEXT, wcslen(TITLE_TEXT), &sTextSize);
// TITLE_TEXT is the string I'm trying to get the width of.
Kann jemand die Formatierung auch bitte korrigieren? Ich bin neu in Stack Overflow und das Codebeispiel funktioniert nicht richtig für mich.