void CLovesisiDlg::OnTimer(UINT nIDEvent)
{
Invalidate();
m_n++;
CString str;
str.Format("第 %d 次刷新",m_n);
this->SetWindowText(str);
CDialog::OnTimer(nIDEvent);
}
void CLovesisiDlg::OnButton1()
{
SetTimer(1,50,NULL);
}
BOOL CLovesisiDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetWindowRect(&rect);
CDC MemDC,mdc;
CBitmap MemBitmap,b1,b2,b3;
mdc.CreateCompatibleDC(NULL);
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(0,0,0));
b1.LoadBitmap(IDB_BITMAP1);
b2.LoadBitmap(IDB_BITMAP2);
b3.LoadBitmap(IDB_BITMAP3);
mdc.SelectObject(&b1);
MemDC.BitBlt(0,0,366,470,&mdc,0,0,SRCCOPY);
mdc.SelectObject(&b2);
MemDC.BitBlt(0,0,366,470,&mdc,0,0,SRCCOPY);
mdc.SelectObject(&b3);
MemDC.BitBlt(0,0,366,470,&mdc,0,0,SRCCOPY);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
//绘图完成后的清理
MemBitmap.DeleteObject();
MemDC.DeleteDC();
// return CDialog::OnEraseBkgnd(pDC);
return true;
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/