19,468
社区成员
发帖
与我相关
我的任务
分享
void CTView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
CRect rect;
GetClientRect(rect);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(rect.Width(),rect.Height());
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(rect.Width()/2,rect.Height()/2);
}
void CTView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CBitmap bitmap;
CDC memdc;
CClientDC dc(this);
OnPrepareDC(&dc);
CRect rect;
GetClientRect(rect);
bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
memdc.CreateCompatibleDC(&dc);
memdc.SelectObject(bitmap);
OnPrepareDC(&memdc);
memdc.DPtoLP(&rect);
memdc.SetBkMode(TRANSPARENT);//此处并不管用.
CBrush brush(RGB(255,0,0));
memdc.FillRect(rect,&brush);
// memdc.SetBkColor(RGB(255,255,0));
memdc.MoveTo(0,0);
memdc.LineTo(250,250);
memdc.Ellipse(-200,-200,200,200);
dc.BitBlt(-200,-200,400,400,&memdc,-200,-200,SRCCOPY);
}