BOOL GetMessage(lpmsg, hwnd, wMsgFilterMin, wMsgFilterMax) | |||||
LPMSG lpmsg; | /* address of structure with message | */ | |||
HWND hwnd; | /* handle of the window | */ | |||
UINT wMsgFilterMin; | /* first message | */ | |||
UINT wMsgFilterMax; | /* last message | */ |
The GetMessage function retrieves a message from a thread's message queue and places the message in an MSG structure. GetMessage retrieves messages associated only with the given window and within the given range of message values. This function does not retrieve messages for windows that belong to other threads or applications.
lpmsg
Points to an MSG structure that receives message information from the thread's message queue. The MSG structure has the following form:
typedef struct tagMSG { /* msg */
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;
hwnd
Identifies the window whose messages are to be retrieved. If this parameter is NULL, GetMessage retrieves messages for any window that belongs to the thread making the call.
wMsgFilterMin
Specifies the integer value of the lowest message value to be retrieved.
wMsgFilterMax
Specifies the integer value of the highest message value to be retrieved.
The return value is TRUE if a message other than WM_QUIT is retrieved. It is FALSE if the WM_QUIT message is retrieved.
An application typically uses the return value to determine whether to terminate the main message loop and exit the program.
The WM_KEYFIRST and WM_KEYLAST constants can be used as filter values to retrieve all messages related to keyboard input; the WM_MOUSEFIRST and WM_MOUSELAST constants can be used to retrieve all mouse-related messages. If the wMsgFilterMin and wMsgFilterMax parameters are both zero, the GetMessage function returns all available messages (without performing any filtering).
PeekMessage, WaitMessage