Custom windows message
#define MY_MSG (WM_USER+1)
// In order to prevent the conflict between the user-defined message ID and the system message ID, the user can only define the ID used after WM_USER (0x0400)
PostThreadMessage puts (queries) a queue message into the message queue of the specified thread, and returns without waiting for the thread to process the message
BOOL PostThreadMessage ( DWORD idThread, // Thread identifier of the received message UINT Msg, // Specify the message to be sent WPARAM wParam, / Additional message specific information LPARAM IParam // Additional message specific information ); // The thread does not have a message queue, this function will fail
The target thread receives the message through the GetMessage () method, and blocks if there is no message
BOOL GetMessage(
LPMSG lpMsg, // The thread ID receiving the message
HWND hWnd, // The handle of the window to get the message, if it is NULL, get the message
UINT wMsgFilterMin of the owning thread , // The integer specifying the minimum message value to be retrieved
UINT wMsgFilterMax // Integer specifying the maximum message value to be retrieved
);
PeekMessage checks the thread message queue for a message, and puts the message (if it exists) in the specified structure (snooping the message in the message queue)
BOOL PeekMessage(
LPMSG IpMsg, // Thread ID to receive the message
HWND hWnd, // Get the window handle of the message, if it is NULL, get the message of the owning thread
UINT wMSGfilterMin, // Integer specifying the minimum message value to be retrieved
UINT wMsgFilterMax, // Integer specifying the maximum message value to be retrieved
UINT wRemoveMsg
);
wRemoveMsg can take the following value
PM_NOREMOVE PeekMessage After processing, the message is not removed from the queue.
After PM_REMOVE PeekMessage processing, the message is removed from the queue.
PM_NOYIELD This flag causes the system not to release threads waiting for the calling program to be idle. PM_NOYIELD can be randomly combined to PM_NOREMOVE or PM_REMOVE