GetMessage ()
Prototype:
BOOL GetMessage (lpmsg lpmsg, HWND hwnd, UINT wmsgfiltermin, uint wmsgfiltermax);
Retrieves a message from the calling threads Queque. The function dispatches incoming sent message until a posted message is available for retrieval.
Gets a message from the calling thread's message queue and places the message in the specified structure (MSG). This function obtains the message that is contacted by the specified window and the message sent by PostThreadMessage. The secondary function accepts a certain range of message values. Messages belonging to other threads or applications are not accepted by GetMessage. After the message is successfully obtained, the thread removes the message from the message team.
The function waits until a message arrives to return a value.
Note:
The application typically uses the return value to determine whether to terminate the main message loop and exit the program.
The GetMessage value accepts the message associated with the window or child window that the parameter HWND identifies. If the HWND is NULL, GetMessage accepts the window message that belongs to the calling thread, and the thread message is sent by the function postthreadmessage () to the calling thread. GetMessage does not accept window messages from other threads or other threads. If the uint wmsgfiltermin, the uint Wmsgfiltermax is 0, then GetMessage returns all the available messages (i.e., scope considerations).
GetMessage does not purge Wm.paint messages from the queue. The message will remain in the queue until processing is complete.
...............................................................................
PeekMessage ()
Prototype
BOOL PeekMessage (lpmsg lpmsg, HWND hwnd, UINT wmsgfiltermin, uint wmsgfiltermax, uint wremovemsg)
Wremovemsg
Determines how messages are handled. This parameter is preferable to one of the following values:
After the Pm_noremove PeekMessage is processed, the message is not removed from the queue.
After the Pm_remove PeekMessage is processed, 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. The Pm_noyield can be combined arbitrarily into pm_noremove or pm_remove.
Note:
Unlike the function GetMessage, GetMessage: Gets the message from the system, removes the message from the system, and belongs to the blocking function. When the system has no messages, GetMessage waits for the next message.
The function Peekmesssge gets the message from the system in a view that does not remove the message from the system, is a non-blocking function, and returns FALSE when the system has no messages, and resumes execution of subsequent code.
PeekMessage usually does not purge WM_PAINT messages from the queue. The message will remain in the queue until processing is complete. However, if the WM_PAINT message has an empty update area, PeekMessage clears the WM_PAINT message from the queue.
GetMessage () and PeekMessage () differences