You may need to process some of the messages you receive from GetMessage before you send them out using DispatchMessage. The most common processing routines are TranslateMessage, TranslateAccelerator, and IsDialogMessage. Some of these routines may dispatch messages internally because the application no longer needs to call DispatchMessage in the main message loop.
You usually call TranslateMessage before you call DispatchMessage. TranslateMessage determines which characters go with keyboard messages. TranslateMessage posts the characters to the message queue to be picked up on the next pass of the message loop.
Use the TranslateAccelerator function to intercept keyboard messages and generate menu commands. Use the IsDialogMessage function to ensure the proper operation of modeless dialog boxes.
You can remove a message from its queue with the GetMessage function. Use the PeekMessage function to examine a message without removing it from its queue. This function fills an MSG structure with information about the message. However, you should use the PeekMessage function in Windows CE carefully. Because the PeekMessage function does not block waiting for a message, it is commonly used in loops in Windows-based desktop platforms. This allows an application to continue processing whether or not there are any messages in its queue. In a Windows CE-based application, if an application does not block waiting for a message or some other event, the kernel cannot put the CPU into low-power mode, which can quickly drain the device's batteries. Also, in Windows CE, PeekMessage does not remove WM_PAINT messages.