BOOL CMyWin::OnEraseBkgnd(CDC* pDC) { return pUE; //return CWnd::OnEraseBkgnd(pDC);//把系统原来的这条语句注释掉。 } |
GetClientRect(rectClient); rgn1.CreateRectRgnIndirect(rectClient); rgn2.CreateRectRgnIndirect(m_rectEdit); if(rgn1.CombineRgn(&rgn1,&rgn2,RGN_XOR) == ERROR)//处理后的rgn1只包括了Edit框之外的客户区域,这样,Edit将不会被我的背景覆盖而导致重画。 { ASSERT(FALSE); return ; } brush.CreateSolidBrush(m_clrBackgnd); pDC->FillRgn(&rgn1,&brush); brush.DeleteObject(); |
void CMyWin::OnPaint() { CPaintDC dc1(this); // device context for painting dcMemory.CreateCompatibleDC(&dc1); CBitmap bmp;//这里的Bitmap是必须的,否则当心弄出一个大黑块哦。 bmp.CreateCompatibleBitmap(&dc1,rectClient.Width(),rectClient.Height()); dcMemory.SelectObject(&bmp); //接下来你想怎么画就怎么画吧。 //dcMemory.FillRect(rectClient,&brush); dc1.BitBlt(0,0,rectClient.Width(),rectClient.Height(),&dcMemory,0,0,SRCCOPY); dcMemory.DeleteDC(); // Do not call CWnd::OnPaint() for painting messages } |