Microsoft Docs – Windows API Reference

GetMessage function

Namespace: Winuser.h

Header: Windows.h

Library: User32.lib

Syntax

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

Parameters

Parameter Type Description
lpMsg LPMSG Pointer to an MSG structure that receives message information.
hWnd HWND Handle to the window whose messages are to be retrieved. If NULL, messages for any window belonging to the current thread are retrieved.
wMsgFilterMin UINT Smallest value of the range of message identifiers to be retrieved. If both filter parameters are zero, no filtering is performed.
wMsgFilterMax UINT Largest value of the range of message identifiers to be retrieved.

Return Value

Returns non‑zero if a message other than WM_QUIT is retrieved; zero if the message is WM_QUIT; and -1 on error. Call GetLastError for extended error information when -1 is returned.

Remarks

Requirements

Client: Windows 2000 or later.
Header: Windows.h (includes Winuser.h)
Library: User32.lib

See Also