If it is in Direct2D, you just call InvalidateRect inside WM_PAINT;
It will be refreshed at the screen refresh rate (60 FPS on my PC), even when you move the window :
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have some problem with my application, I want to WM_PAINT is called everytime, that is, "real-time".
Here is my message loop code:
while (true) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
InvalidateRect(state.hwnd, NULL, FALSE); // this line should execute everytime, no matter what.
}
This works perfectly, the WM_PAINT is called everytime. However, when I try to drag the window, the window stops receiving WM_PAINT!
It fully stops, until the mouse button is up. I don't want this behavior.
Any workaround to this?
Regards, @thebluetropics
If it is in Direct2D, you just call InvalidateRect inside WM_PAINT;
It will be refreshed at the screen refresh rate (60 FPS on my PC), even when you move the window :
Hello @thebluetropics ,
In InvalidateRect
document
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 or ValidateRgn 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.If the bErase parameter is TRUE for any part of the update region, the background is erased in the entire region, not just in the specified part.
InvalidateRect(state.hwnd, NULL, FALSE);
UpdateWindow(state.hwnd);
If you want to refresh the invalid area immediately, you can call the UpdateWindow after calling the InvalidateRect
. If any part of the client area is invalid, the UpdateWindow
will cause Windows to call the window process with the WM_PAINT
message (if the entire client area is valid, the window process is not called). This WM_PAINT
message does not enter the message queue and directly call the window process by Windows. After the window is refreshed, it will be exited immediately. Windows will control the statement to the statement after the UpdateWindow
call in the program.
Thank you.
Junjie
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.