User32GetMessage(NativeMessage, HandleRef, UInt32, UInt32) Method

Retrieves a message from the calling thread's message queue.

The function dispatches incoming sent messages until a posted message is available for retrieval.

Unlike GetMessage(NativeMessage, IntPtr, UInt32, UInt32), the PeekMessage(NativeMessage, IntPtr, UInt32, UInt32, PeekMessageFlags) function does not wait for a message to be posted before returning.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static bool GetMessage(
	out NativeMessage refMsg,
	[OptionalAttribute] HandleRef hWnd,
	[OptionalAttribute] uint msgFilterMin,
	[OptionalAttribute] uint msgFilterMax
)

Parameters

refMsg  NativeMessage
A pointer to a structure that receives message information from the thread's message queue.
hWnd  HandleRef  (Optional)
A handle to the window whose messages are to be retrieved. The window must belong to the current thread.

If hWnd is Zero, GetMessage(NativeMessage, IntPtr, UInt32, UInt32) retrieves messages for any window that belongs to the current thread, and any messages on the current thread's message queue whose Hwnd value is Zero. Therefore if hWnd is Zero, both window messages and thread messages are processed.

If hWnd is -1, GetMessage(NativeMessage, IntPtr, UInt32, UInt32) retrieves only messages on the current thread's message queue whose Hwnd value is Zero, that is, thread messages as posted by PostMessage(IntPtr, EditControlMessages, IntPtr, IntPtr) (when the hWnd parameter is Zero) or PostThreadMessage(Int32, WindowMessages, IntPtr, IntPtr).

msgFilterMin  UInt32  (Optional)
The integer value of the lowest message value to be retrieved. Use WM_KeyFirst to specify the first keyboard message or WM_MouseFirst to specify the first mouse message.

Use WM_Input here and in msgFilterMax to specify only the WM_Input messages.

If msgFilterMin and msgFilterMax are both zero, GetMessage(NativeMessage, IntPtr, UInt32, UInt32) returns all available messages (that is, no range filtering is performed).

msgFilterMax  UInt32  (Optional)
The integer value of the highest message value to be retrieved. Use WM_KeyLast to specify the last keyboard message or WM_MouseLast to specify the last mouse message.

Use WM_Input here and in msgFilterMin to specify only the WM_Input messages.

If msgFilterMin and msgFilterMax are both zero, GetMessage(NativeMessage, IntPtr, UInt32, UInt32) returns all available messages (that is, no range filtering is performed).

Return Value

Boolean
If the function retrieves a message other than WM_Quit, the return value is .

If the function retrieves the WM_Quit message, the return value is .

If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or refMsg is an invalid pointer.

To get extended error information, call GetLastWin32Error.

Remarks

See Also