CDuiString m_test_string = _T("测试字符串")
HDC m_hDc = m_pm.GetPaintDC();
// 100 是xml中配置的字体的编号
HFONT hFont = m_pm.GetFont(100);
::SelectObject(m_hDc, hFont);
SIZE size;
GetTextExtentPoint32(m_hDc, m_test_string, i, &size);
return size.cx
The GetTextExtentPoint32 function computes the width and height of the specified string of text.
本文介绍了一种使用GetTextExtentPoint32函数计算特定文本字符串宽度和高度的方法,此函数适用于需要精确测量文本尺寸的场景。
2万+

被折叠的 条评论
为什么被折叠?



