先看下MSDN上的解释
RedrawWindow:
This function updates the specified rectangle or region in the client area of a window.
InvalidateRect:
This function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.
RedrawWindow的作用是更新客户区的区域,可以是矩形或者非矩形.
InvalidateRect的作用是往窗口的需要重绘的区域中添加矩形.
揪出这两个函数来是因为有一个要显示类似即使速度的东西.用static实现,但是发现绘制会有重影.
调用InvalidateRect之后发现还是有时候会有重影.
也就是说InvalidateRect并不会立即更新.
The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect function.
The system sends a WM_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.
看看msdn上的解释.也就是说,当当前窗口没有其他消息的时候,而且当前需重绘区域不为空,才会发送WM_PAINT消息.
而如果要实现即时的绘制.
RedrawWindow这个函数派上用场啦.
RedrawWindow 可以设置几种更新的方式,具体可以参考msdn.
也就是说微软提供了一个可以强制更新和非强制更新的手段让你来重绘.
补充:
另外补充一个绘制的api
UpdateWindow
看msdn
This function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty.
UpdateWindow sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue.
If the update region is empty, no message is sent.
这个函数只负责重绘.但是不会发送WM_ERASEBKGND消息.所有这是跟RedrawWindow的区别