User32PeekMessage(NativeMessage, IntPtr, UInt32, UInt32, PeekMessageFlags) Method

Dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist).

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)]
public static bool PeekMessage(
	out NativeMessage refMsg,
	[OptionalAttribute] IntPtr hWnd,
	[OptionalAttribute] uint msgFilterMin,
	[OptionalAttribute] uint msgFilterMax,
	[OptionalAttribute] PeekMessageFlags flags
)

Parameters

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

If hWnd is Zero, PeekMessage(NativeMessage, IntPtr, UInt32, UInt32, PeekMessageFlags) 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, PeekMessage(NativeMessage, IntPtr, UInt32, UInt32, PeekMessageFlags) retrieves only messages on the current thread's message queue whose Hwnd value is Zero, that is, thread messages as posted by PostMessage (when the hWnd parameter is Zero) or PostThreadMessage(Int32, WindowMessages, IntPtr, IntPtr).

msgFilterMin  UInt32  (Optional)
The value of the first message in the range of messages to be examined. Use WM_KeyFirst to specify the first keyboard message or WM_MouseFirst to specify the first mouse message.

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

msgFilterMax  UInt32  (Optional)
The value of the last message in the range of messages to be examined. Use WM_KeyLast to specify the last keyboard message or WM_MouseLast to specify the last mouse message.

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

flags  PeekMessageFlags  (Optional)
Specifies how messages are to be handled.

Return Value

Boolean
If the function succeeds, the return value is .

If the function fails, the return value is .

To get extended error information, call GetLastWin32Error.

Remarks

See Also