Why the PeekMessage always return TRUE?
-
24-05-2021 - |
문제
// Main message loop
MSG msg;
ZeroMemory( &msg, sizeof( msg ) );
while(msg.message!=WM_QUIT)
{
if(PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
Render();
}
}
The "render" function hasn't been executing
해결책
The PeekMessage
documentation says this regarding the return value:
If a message is available, the return value is nonzero.
If no messages are available, the return value is zero.
When the message queue is empty, it will indeed return zero, i.e. FALSE
. The conclusion therefore is that the message queue is never empty. And the most likely explanation for that is that one of the messages you handle in DispatchMessage
leads to that same message being posted to the queue.
제휴하지 않습니다 StackOverflow