BOOL CXXXDlg::OnEraseBkgnd(CDC *pDC) { CRect rect; this->GetClientRect(rect); if(!m_pBkImage) //定义的一个成员变量 { m_pBkImage = new Image(_T("main_frame.png")); } Bitmap bmp(rect.right, rect.bottom); Graphics bmpGraphics(&bmp); bmpGraphics.SetSmoothingMode(SmoothingModeAntiAlias); bmpGraphics.DrawImage(m_pBkImage, 0, 0, rect.Width(), rect.Height()); //Drawing on bitmap Graphics graphics(pDC->m_hDC); //Drawing on DC CachedBitmap cachedBmp(&bmp,&graphics); graphics.DrawCachedBitmap(&cachedBmp, 0, m_iCaptionH); graphics.ReleaseHDC(pDC->m_hDC); return TRUE; }