InvalidateRect(hctrl,null,true) ; 
UpdateWindow(hctrl);
这两个函数组合起来是什么意思呢?InvalidateRect会直接调用WM_PAINT ,UpdateWindow会向指定的窗口发送WM_PAINT。。
那他们的先后顺序是怎么呢?请大家指教一下。。谢谢! 

解决方案 »

  1.   

    InvalidateRect()函数将触发OnPaint()函数,然后触发OnDraw()
    UpdateWindow();//强制在此时发送WM_PAINT消息   
      

  2.   

    先后顺序如下:先InvalidateRect---->再UpdateWindow.
      

  3.   

    InvalidateRect是会触发WM_PAINT事件,但是不是立即就触发,一般都会等当前操作的过程结束才触发,如果需要立即触发,那么配合UpdateWindow()使用就可以了。先执行InvalidateRect,再执行UpdateWindow().
      

  4.   

    一:什么时候才会发生重绘窗口的消息?      当需要更新或重新绘制窗口的外观时,应用程序就会发送WM_PAINT消息。对窗口进行重新绘制。二:Invalidate() -- RedrawWindow() -- UpdateWindow()三个函数有什么异同?      Invalidate()是强制系统进行重画,但是不一定就马上进行重画。因为Invalidate()只是通知系统,此 时的窗口已经变为无效。强制系统调用WM_PAINT,而这个消息只是Post就是将该消息放入消息队列。当执行到WM_PAINT消息时才会对敞口进行重绘。     UpdateWindow只向窗体发送WM_PAINT消息,在发送之前判断GetUpdateRect(hWnd,NULL,TRUE)看有无可绘制的客户区域,如果没有,则不发送WM_PAINT。     RedrawWindow()则是具有Invalidate()和UpdateWindow()的双特性。声明窗口的状态为无效,并立即更新窗口,立即调用WM_PAINT消息处理。
      

  5.   

    UpdateWindow function to force the WM_PAINT message to be sent immediately. If there is any invalid part of the client area, UpdateWindow sends the WM_PAINT message for the specified window directly to the window procedure.