[win32] Messages
source #
- Every window class has an associated message handling function (
Window Proc) - All messages towards windows of a window class go to its window proc
- If an application does not respond to messages for a few seconds it is counted as not responding.
- There are two kinds of messages:
-
Unqueued messages : Windows calls the window proc directly with messages. This happens for example for
WM_ACTIVATE,WM_SETFOCUSandWM_SETCURSOR.[I believe this can happen whenever we yield back to the system. These functions yield:
WaitMessage(explicit yield)DialogBoxDialogBoxIndirectDialogBoxIndirectParamDialogBoxParamGetMessageMessageBoxPeekMessageSendMessage
]
-
Queued messages: Are posted to a FIFO message queue. It is the application’s responsibility to pull messages off the queue via
GetMessageorPeekMessage, and dispatch them to their corresponding window proc viaDispatchMessage. Not all queued messages are processed in FIFO though.WM_PAINT,WM_TIMER, andWM_QUITare kept in the queue until there are no other messages left. Also, multipleWM_PAINTmessages are combined into oneWM_PAINTmessage, that covers the union of all the to-be-redrawn area.
-
- You can send your own messages in two ways
PostMessage: Creates a queued messageSendMessage: Create an unqueued message
- The system does not automatically create a message queue for each thread. Instead, the system creates a message queue only for threads that perform operations which require a message queue. [source ]