[C++] WinAPI: How to Get Text Extent Pixel Size
#include <windows.h>
HDC hdc = GetDC(NULL);
int nHeight = -MulDiv(m_nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
HFONT hfont;
if (m_bBold)
hfont = CreateFontW(nHeight, 0, 0, 0, FW_BOLD, m_bItalic, FALSE,
FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, m_sFontName);
else
hfont = CreateFontW(nHeight, 0, 0, 0, FW_NORMAL, m_bItalic, FALSE,
FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, m_sFontName);
SelectObject(hdc, hfont);
SIZE textsize;
::GetTextExtentPoint32W(hdc, m_sText, wcslen(m_sText), &textsize); // <------------- To Get Size!
DeleteObject(hfont);
ReleaseDC(NULL, hdc);