The WinGetMsg function retrieves messages from the message queue based on message priority. WinGetMsg retrieves messages with higher priority first. If it finds more than one message at a particular priority level, it retrieves the oldest message first. Messages have the following priorities:
┌───────────────┬─────────────────────────────────────────────┐ │Priority │Message │ ├───────────────┼─────────────────────────────────────────────┤ │1 │WM_SEM1 │ ├───────────────┼─────────────────────────────────────────────┤ │2 │Messages posted using WinPostMsg │ ├───────────────┼─────────────────────────────────────────────┤ │3 │Input messages from the keyboard or mouse │ ├───────────────┼─────────────────────────────────────────────┤ │4 │WM_SEM2 │ ├───────────────┼─────────────────────────────────────────────┤ │5 │WM_PAINT │ ├───────────────┼─────────────────────────────────────────────┤ │6 │WM_SEM3 │ ├───────────────┼─────────────────────────────────────────────┤ │7 │WM_TIMER │ ├───────────────┼─────────────────────────────────────────────┤ │8 │WM_SEM4 │ └───────────────┴─────────────────────────────────────────────┘