VC6.0,MFC程序里在VIEW::ONPAINT()中加入,如下:
void CSDView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
RECT rt1,rt2;
int height1,height2,width1,width2;
GetClientRect(&rt1); //客户区大小
GetWindowRect(&rt2); //整个窗口大小
height1=rt1.bottom - rt1.top;
width1=rt1.right -rt1.left;
height2=rt2.bottom - rt2.top;
width2=rt2.right -rt2.left;
//转换成string
CString str,str1,str2,str3,str4;
str1.Format("%d",height1);
str2.Format("%d",height2);
str3.Format("%d",width1);
str4.Format("%d",width2);
str=str3+ "," + str4 + ","+str1+","+str2;
//_T转换成LPCSTR
dc.DrawText(_T(str),strlen(_T(str), &rt1, DT_CENTER);
// Do not call CView::OnPaint() for painting messages
}