在OnPaint函数中,用CClientDC dc(this)代替CPaintDC(this)后,界面不断闪烁。

说明:CClientDC是对GetDC的使用封装, CPaintDC是对BeginPaint/EndPaint的使用封装

原因:BeginPaint/EndPaint会将无效区域设置为NULL, 从而通知系统已经绘制了,不用再发WM_PAINT消息,

而GetDC不会这样做,若在OnPaint函数中直接调用GetDC来获得设备进行绘制,不做其它操作,系统会不断的

发送WM_PAINT消息,从而导致不断重绘而闪烁。

以下摘自MSDN,

BeginPaint sets the update region of a window to NULL. This clears the region, preventing it from generating subsequent WM_PAINT messages. If an application processes a WM_PAINT message but does not call BeginPaint or otherwise clear the update region, the application continues to receive WM_PAINT messages as long as the region is not empty. In all cases, an application must clear the update region before returning from the WM_PAINT message.

After the application finishes drawing, it should call EndPaint. For most windows, EndPaint releases the display device context, making it available to other windows. EndPaint also shows the caret, if it was previously hidden by BeginPaint. BeginPaint hides the caret to prevent drawing operations from corrupting it.

最新文章

  1. 阶段一:AsyncTask的三个属性值和四个步骤
  2. SpringMVC接收Post的实体/JSon数据
  3. 脱壳脚本_手脱壳ASProtect 2.1x SKE -> Alexey Solodovnikov
  4. D3.js 插入元素,删除元素
  5. 异步任务神器 Celery 简明笔记
  6. 封装好的PHP分页类,简单好用--在开源看到的,取回来自己用
  7. 【转】linux之自建yum仓库
  8. Linux读取文件路径问题
  9. configure HDFS(hadoop 分布式文件系统) high available
  10. 重读The C programming Lanuage 笔记三:简单计算器程序
  11. POCO系列之——延迟加载
  12. 利用nodeJs来安装less以及编译less文件为css文件
  13. python运算符重载(二)
  14. SpringBoot系列: CommandLineRunner接口的用处
  15. GET 和 POST 请求的优缺点和误区
  16. mysql 开发进阶篇系列 25 数据库RPM安装目录介绍
  17. 如何创建magento模块z之Hello World例子(转)
  18. linq join 左连接 leftjoin 多个on条件 where 条件
  19. SWIFT中数字格式
  20. hdu1080 DP(类最长公共子序列)

热门文章

  1. DICOM医学图像处理:Orthanc Plugin SDK实现WADO服务
  2. mac异常删除管理员账户恢复操作
  3. Hibernate中的条件查询完毕类
  4. vue native
  5. 有关C/C++指针的经典面试题(转)
  6. mysql的安装、C++訪问mysql数据库、编码设置问题
  7. C和C++代码精粹笔记1
  8. 数据库历险记(三) | 缓存框架的连环炮 数据库历险记(二) | Redis 和 Mecached 到底哪个好? 数据库历险记(一) | MySQL这么好,为什么还有人用Oracle? 面对海量请求,缓存设计还应该考虑哪些问题?
  9. 笔记08 throw e 和throw 的区别
  10. 笔记04 WPF对象引用