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.