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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章