MFC 画图 老是闪烁 求高手指点 70
voidCSnake_ServerDlg::DrawMap(CDC*pDC,CRectrect,intRed,intwhite,intGreen){//画图代码CDCMe...
void CSnake_ServerDlg::DrawMap(CDC *pDC,CRect rect,int Red,int white,int Green)
{//画图代码
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(), rect.Height());
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(rect.left, rect.top, rect.Width(), rect.Height(),RGB(Red,white,Green));
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),&MemDC,0,0,SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
}
调用的代码
void CSnake_ServerDlg::OnPaint()
{
CDC *pDC=this->GetDC();
CRect rect;
pDC->GetClipBox(&rect);
DrawMap(pDC,rect,100,100,0);
CRect rect1;
rect1.left= rect.left+50;
rect1.top = rect.left+20;
rect1.right = rect.Width()-20;
rect1.bottom =rect.Height()-20;
DrawMap(pDC,rect1,100,100,255);
}
在线等啊 展开
{//画图代码
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(), rect.Height());
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(rect.left, rect.top, rect.Width(), rect.Height(),RGB(Red,white,Green));
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),&MemDC,0,0,SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
}
调用的代码
void CSnake_ServerDlg::OnPaint()
{
CDC *pDC=this->GetDC();
CRect rect;
pDC->GetClipBox(&rect);
DrawMap(pDC,rect,100,100,0);
CRect rect1;
rect1.left= rect.left+50;
rect1.top = rect.left+20;
rect1.right = rect.Width()-20;
rect1.bottom =rect.Height()-20;
DrawMap(pDC,rect1,100,100,255);
}
在线等啊 展开
2个回答
展开全部
你把memdc那段移植到OnPaint中,然后将memdc传给DrawMap, 之后在OnPaint中bitblt到窗口DC
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(), rect.Height());
DrawMap(&MemDC...
...
pDC->BitBlt(
最后pDC->ReleaseDC
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(pDC);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(), rect.Height());
DrawMap(&MemDC...
...
pDC->BitBlt(
最后pDC->ReleaseDC
追问
麻烦你给改下代码,我直接拷贝出来用哈
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询