GDI+ 双缓冲

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;
}
posted @ 2013-04-27 18:28  奥雷连诺  阅读(177)  评论(0编辑  收藏  举报