MFC 编程CDC方法GetTextExtent and DrawText DT_CALCRECT
CString str = _T("WWWWWWWW");
CRect r(0,0,0,0);
pDC->DrawText(str, r, DT_CALCRECT);
CSize s = pDC->GetTextExtent(str);
CRect rect(CPoint(100,100),s);
pDC->DrawText(str,rect,DT_LEFT);
rect.top+=10;
pDC->Rectangle(rect);
pDC->Rectangle(r);
为什么在另一个程序就的到不同的大小呢, 终于发现原来是CDC中使用的字体有所不同,大小就会不同。。。 |