本文主要是介绍[MFC]OnPaint双缓冲绘图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
void CXButton::OnPaint()
{CRect PaintRect;CPaintDC dc(this);CDC MemDC;CBitmap MemBitmap;// 双缓冲绘图GetClientRect(PaintRect);if (MemDC.CreateCompatibleDC(&dc)){if (MemBitmap.CreateCompatibleBitmap(&dc, PaintRect.Width(), PaintRect.Height())){if (HGDIOBJ OldObject = MemDC.SelectObject(MemBitmap)){// 拷贝背景图, 以处理透明色if (MemDC.BitBlt(0, 0, PaintRect.Width(), PaintRect.Height(), &dc, 0, 0, SRCCOPY)){Gdiplus::Graphics g(MemDC);// Paint here ...dc.BitBlt(0, 0, PaintRect.Width(), PaintRect.Height(), &MemDC, 0, 0, SRCCOPY);}MemDC.SelectObject(OldObject);}MemBitmap.DeleteObject();}MemDC.DeleteDC();}
}
这篇关于[MFC]OnPaint双缓冲绘图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!