|||
可以新建一个MFC App
创建一个Button,单击button 显示图形
CRect rc(10,10,200,200);
//GetClientRect(rc);
int nWidth=rc.Width();
int nHeight=rc.Height();
CDC *pDC=GetDC();
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);
CBitmap *pOldBitmap=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(255,255,255));
//此处添加需要显示图形的代码
//MoveTo LineTo.....
MemDC.MoveTo(0,0);
MemDC.LineTo(100,100);
pDC->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
MemDC.DeleteDC();