CWnd::UpdateWindow();
和CWnd::Invalidate()调用WM_PAINT时有什么区别

解决方案 »

  1.   

    CWnd::UpdateWindow();是直接发送消息,而CWnd::Invalidate()是发送到消息队列
      

  2.   

    CWnd::UpdateWindow()直接调用WM_PAINT的处理过程,重画工作马上执行
    CWnd::Invalidate()把WM_PAINT送到消息队列,什么时候执行重画,你无法控制。
      

  3.   

    CWnd::UpdateWindow():
       Updates the client area by sending aWM_PAINT message if the update region is not empty. The UpdateWindow member function sends a WM_PAINT message directly, bypassing the application queue. If the update region is empty, WM_PAINT is not sent.
    CWnd::Invalidate():
       Invalidates the entire client area of CWnd. The client area is ed for painting when the next WM_PAINT message occurs. The region can also be validated before a WM_PAINT message occurs by the ValidateRect or ValidateRgn member function.
      

  4.   

    Invalidate()声明客户区无效,当下一个WM_PAINT 到来时无效区域被更新重绘。
    通常当存在无效区域且windows空闲时,windows就以送一个WM_PAINT 使之更新。UpdateWindow();强制立即发送WM_PAINT 消息,当存在无效区域时就立即更新重绘。如果没有被声明无效的区域,它不起作用。