zoukankan      html  css  js  c++  java
  • BeginPaint/EndPaint(CPaintDC)与GetDC(CClientDC)的区别

    在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. 

  • 相关阅读:
    Git 9. 远程仓库
    Git 8. 删除文件
    Git 7. 撤销修改
    # 并发编程 -进程理论-进程的方法
    socket 上传 -- 异常处理--UDP协议 --自定义socket #29
    socket(套接字)
    面向过程补充 网络编程 #27
    ATM
    选课系统 -- # 25 -26
    面向对象高级 1.反射 2.元类 # 24
  • 原文地址:https://www.cnblogs.com/shanql/p/6574388.html
Copyright © 2011-2022 走看看