双缓冲绘图,防止闪烁
2010-12-05 21:53
232 查看
void CBMSView::OnDraw(CDC* pDC) { CBitmap bmp; if (bmp.LoadBitmap(IDB_BITMAP_MAP))//绘出楼层平面图 { // Get the size of the bitmap BITMAP bmpInfo; bmp.GetBitmap(&bmpInfo); // Create an in-memory DC compatible with the // display DC we're using to paint CDC dcMemory; dcMemory.CreateCompatibleDC(pDC); // bmp.CreateCompatibleBitmap(&dcMemory, bmpInfo.bmWidth, bmpInfo.bmHeight); // Select the bitmap into the in-memory DC CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp); // Find a centerpoint for the bitmap in the client area CRect rect; GetClientRect(&rect); // Copy the bits from the in-memory DC into the on- // screen DC to actually do the painting. Use the centerpoint // we computed for the target offset. pDC->BitBlt(rect.left ,rect.top,rect.Width(),rect.Height(), &dcMemory, 0, 0, SRCCOPY); dcMemory.SelectObject(pOldBitmap); } else { TRACE0("ERROR: Where's IDB_BITMAP_MAP?/n"); } }
注意:应用到mfc项目dcMemory,bmp应为类成员,否则闪烁严重
PS.摘自MSDN
相关文章推荐
- VC绘图防止屏幕闪烁
- [转载] MFC绘制动态曲线,用双缓冲绘图技术防闪烁
- MFC绘制动态曲线,用双缓冲绘图技术防闪烁
- VC的内存绘图防止屏幕闪烁技术的实现
- 关于内存DC绘图防止屏幕闪烁说明
- C# 在PictureBox 中绘图防止闪烁的办法
- vb.net中利用双缓冲绘图技术解决listview加载数据闪烁的问题
- 双缓冲应用 之 窗口绘图防闪烁,基于对话框的绘图
- 关于内存DC绘图防止屏幕闪烁说明(亦即双缓存技术) .
- 关于内存DC绘图防止屏幕闪烁说明
- 【GDI绘图】防止闪烁
- 某些情况下闪烁是不能避免的 VC 绘图 双缓冲
- MFC绘制动态曲线,用双缓冲绘图技术防闪烁
- MFC绘制动态曲线,用双缓冲绘图技术防闪烁
- MFC 双缓冲多重绘图去除闪烁的万能函数模板
- MFC绘制动态曲线,用双缓冲绘图技术防闪烁
- 关于内存DC绘图防止屏幕闪烁
- 关于内存DC绘图防止屏幕闪烁说明
- [C#技术参考]在PictureBox 中绘图防止闪烁的办法
- VC的内存绘图防止屏幕闪烁技术的实现