Last active
March 20, 2022 08:34
-
-
Save Vladimir-Novick/9a8ad206aaa32a484bb2b61098d92054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POINT CDefaultAppFont::GetFontSize(CFont* pFont,CHAR *str) | |
{ | |
POINT p = { 0 }; | |
auto mainWindow = AfxGetApp()->GetMainWnd(); | |
if (mainWindow != NULL) { | |
auto hDC = GetWindowDC(mainWindow->m_hWnd); | |
CDC* pDC = CDC::FromHandle(hDC); | |
CFont* pOldFont = pDC->SelectObject(pFont); | |
SIZE sizeText; | |
if (str == NULL) { | |
GetTextExtentPoint32(pDC->m_hDC, "Z", 1, &sizeText); | |
} | |
else { | |
GetTextExtentPoint32(pDC->m_hDC, str, strlen(str), &sizeText); | |
} | |
pDC->SelectObject(pOldFont); | |
p.y = sizeText.cy; | |
p.x = sizeText.cx; | |
} | |
return p; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment