Reputation: 793
I want to draw an image on an HWND
immediately (by the time the function returns, the image would have been drawn). So I am thinking of using UpdateWindow()
to do that, as I have read, UpdateWindow()
will send a WM_PAINT message by calling the Window Procedure directly, and not by placing a WM_PAINT message in the message queue.
But there is one think that I am not sure of, UpdateWindow()
documentation says the following:
If the update region is empty, no message is sent.
What does "empty" means? Does it mean validated? If so, should I call InvalidateRect()
before calling UpdateWindow()
?
Upvotes: 0
Views: 1748
Reputation: 37202
If there are no update regions marked as invalid then UpdateWindow
does nothing, as the documentation says. If you call InvalidateRect
first then the update region would not be empty and UpdateWindow
would trigger a WM_PAINT
as expected.
If you want to force a redraw to complete immediately, the easiest way is with the RedrawWindow
function. This lets you simultaneously mark a region as invalid, and force the redraw to take place before the command returns. For example, this will forcibly redraw the entire client area:
RedrawWindow(hWnd, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW);
Upvotes: 2