If system or queue hooks are installed, they are called before this function returns.
rc is generally used to determine when to terminate the application's main loop and exit the program.
hwndFilter constrains the returned message to be for a specific window or its children. When hwndFilter is null, the returned message can be for any window. The message identity is restricted to the range of message identities specified by ulFirst and ulLast inclusive. When ulFirst and ulLast are both zero, any message satisfies the range constraint. When ulFirst is greater than ulLast, messages except those whose identities lie between ulFirst and ulLast are eligible to be returned. Messages that do not conform to the filtering criteria remain in the queue.
When hwndFilter is null, and ulFirst and ulLast are both zero, all messages are returned in the order that they were posted to the queue.
By using filtering, messages can be processed in an order that is different from the one in the queue. Filtering is used in situations where applications receive messages of a particular type, rather than having to deal with other types of message at an inconvenient point in the logic of the application. For example, when a "mouse down" message is received, filtering can be used to wait for the "mouse up" message without having to be concerned with receiving other messages.
These constants can also be used when filtering messages:
WM_MOUSEFIRST
Great care must be taken if filtering is used, to ensure that a message that satisfies the specification of the filtering parameters can occur, otherwise this function cannot complete. For example, calling this function with ulFirst and ulLast equal to WM_CHAR and with hwndFilter set to a window handle that does not have the input focus, prevents this function from returning.
Keystrokes are passed to the WinTranslateAccel call, which implies that accelerator keys are translated into WM_COMMAND or WM_SYSCOMMAND messages, and so are not seen as WM_CHAR messages by the application.
Note: An application must be prepared to receive messages other than those documented in this publication. All messages that an application does not want to handle should be dispatched to the appropriate window procedure using the WinDispatchMsg function.