Microsoft Windows CE 3.0  

GetMessage

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This function retrieves a message from the calling thread's message queue and places it in the specified structure.

BOOL
GetMessage(
LPMSG
lpMsg
,
HWND
hWnd
,
UINT
wMsgFilterMin
,
UINT
wMsgFilterMax
);

Parameters

lpMsg
[out] Long pointer to an MSGstructure that receives message information from the thread's message queue.
hWnd
[in] Handle to the window whose messages are to be retrieved. One value has a special meaning:
Value Description
NULL GetMessageretrieves messages for any window that belongs to the calling thread and thread messages posted to the calling thread by means of PostThreadMessage.
wMsgFilterMin
[in] Specifies the integer value of the lowest message value to be retrieved.
wMsgFilterMax
[in] Specifies the integer value of the highest message value to be retrieved.

Return Values

Nonzero indicates that the function retrieves a message other than WM_QUIT. Zero indicates that the function retrieves the WM_QUIT message, or that lpMsgis an invalid pointer. –1 indicates that an error occurred—for example, the function fails if hWndis an invalid window handle. To get extended error information, call GetLastError.

Remarks

An application typically uses the return value to determine whether to end the main message loop and exit the program.

The GetMessagefunction only retrieves messages associated with the window identified by the hWndparameter or any of its children, as specified by the IsChildfunction, and within the range of message values given by the wMsgFilterMinand wMsgFilterMaxparameters. If hWndis NULL, GetMessageretrieves messages for any window that belongs to the calling thread and thread messages posted to the calling thread by means of PostThreadMessage. GetMessagedoes not retrieve messages for windows that belong to other threads nor for threads other than the calling thread, even if hWndis not NULL. Thread messages, posted by the PostThreadMessagefunction, have a message hWndvalue of NULL. If wMsgFilterMinand wMsgFilterMaxare both zero, GetMessagereturns all available messages (that is, no range filtering is performed).

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 messages. If the wMsgFilterMinand wMsgFilterMaxparameters are both zero, the GetMessagefunction returns all available messages (that is, without performing any filtering).

GetMessagedoes not remove WM_PAINTmessages from the queue. The messages remain in the queue until processed.

Note that the function return value can be nonzero, zero, or –1. Thus, you should avoid code like this:

while (GetMessage( lpMsg, hWnd, 0, 0)) ...

The possibility of a –1 return value means that such code can lead to fatal application errors.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h   Msgque.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

GetLastError, IsChild, PeekMessage, PostMessage, PostThreadMessage, WM_PAINT, WM_QUIT, MSG