I am trying to understand "The Message Loop". Here's what it looks like:
MSG msg = { }; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); }
So far I understand (at least I hope) with the concept. When a user interacts with a Windows application using the keyboard and mouse, these events are converted into the corresponding messages by the corresponding device drivers and sent to the system message queue.
The OS deletes messages from the queue one by one and analyzes each of them to send them to the corresponding application thread queue, which is responsible for creating the destination window.
Now in my application
MSG msg; GetMessage(&msg, NULL, 0, 0);
removes the message from the stream-specific message queue and populates the MSG structure.
But they say that TranslateMessage converts virtual keystrokes to characters and sends them back to the call flow message queue.
DispatchMessage directs the OS to invoke the Windows procedure of the corresponding target window.
Two doubts:
1) What is the exact functionality of TranslateMessage, is it just to translate virtual keystrokes to symbolic messages (I assume that virtual keystrokes are keystrokes other than alphabets and numbers), if the character message is sent back to the queue, is the loop not broken?
2) What about mouse events? Are they shipped directly?
source share