The real difference here is between the PeekMessage and the GetMessage function behaviour
When GetMessage checks the message queue, if there are no messages it waits for a message to become available.
When PeekMessage checks the queue, if there is a message available then PeekMessage returns it, if there is no message available then PeekMessage
returns anyway.
So GetMessage will always return with a message even if it has to wait for a long long time.
PeekMessage does not wait if there is no message available in the queue - it will return with or without a message.
So with PeekMessage you need to check if it got a message
usingif(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) //check if PeekMessage found a message in the queue