15,978
社区成员
发帖
与我相关
我的任务
分享
void CTrackerView::OnButtonTest()
{
// TODO: Add your command handler code here
CClientDC dc(this);
OnPrepareDC(&dc);
CTrackerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CDC memdc;
CRect rect;
GetClientRect(rect);
dc.DPtoLP(rect);rect.NormalizeRect();
CString str;
str.Format("%d %d %d %d\n%d %d",rect.left,rect.top,rect.right,rect.bottom,rect.Width(),rect.Height());
MessageBox(str);
memdc.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
CBrush brush(RGB(0,255,0));
memdc.SelectObject(&bitmap);
memdc.FillRect(rect,&brush);
memdc.Ellipse(400-40,400-40,400+40,400+40);
memdc.TextOut(400,400,"hello");
dc.BitBlt(0,0,rect.Width(),rect.Height(),&memdc,0,0,SRCCOPY);
dc.TextOut(450,450,"world");
}
void CTrackerView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CRect rect;
GetClientRect(rect);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(800,800);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(0,rect.Height());
}