{I+=codeWee;}
[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);
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.