CString str=_T("TEST");
//set the font
CFont *font=new CFont();
LOGFONT lf;
ZeroMemory(&lf,sizeof(lf));
lf.lfHeight = 0;
lf.lfQuality =2;
lf.lfWeight =1000;
lf.lfItalic = 0;
lf.lfWidth =10;
strcpy(lf.lfFaceName, _T("宋体"));
font->CreateFontIndirect(&lf);
CDC MemDC;
MemDC.CreateCompatibleDC(NULL);
MemDC.SelectObject((HGDIOBJ)font->m_hObject);
//Get the accurate TEXT's Draw RECT;
CRect rc(0,0,0,0);
MemDC.DrawText(str, &rc, DT_CALCRECT);
int nWidth =rc.Width();
int nHeight =rc.Height();
DxTRACE(_T("rc's Width:%d,rc's Height:%d/n"),nWidth, nHeight);
CRect m_rect;//存储实际显示区域的大小
m_rect.top=0;
m_rect.bottom=m_rect.top+nHeight;
m_rect.left=0;
m_rect.right=m_rect.left+nWidth;
MemDC.DeleteDC();
font->DeleteObject();