Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Add MsgWaitForMultipleObjectsEx #450

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/User32/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ PInvoke.User32.MenuObject
PInvoke.User32.MenuObject.OBJID_CLIENT = 4294967292 -> PInvoke.User32.MenuObject
PInvoke.User32.MenuObject.OBJID_MENU = 4294967293 -> PInvoke.User32.MenuObject
PInvoke.User32.MenuObject.OBJID_SYSMENU = 4294967295 -> PInvoke.User32.MenuObject
PInvoke.User32.MsgWaitForMultipleObjectsExFlags
PInvoke.User32.MsgWaitForMultipleObjectsExFlags.MWMO_ALERTABLE = 2 -> PInvoke.User32.MsgWaitForMultipleObjectsExFlags
PInvoke.User32.MsgWaitForMultipleObjectsExFlags.MWMO_INPUTAVAILABLE = 4 -> PInvoke.User32.MsgWaitForMultipleObjectsExFlags
PInvoke.User32.MsgWaitForMultipleObjectsExFlags.MWMO_WAITALL = 1 -> PInvoke.User32.MsgWaitForMultipleObjectsExFlags
PInvoke.User32.MsgWaitForMultipleObjectsExFlags.None = 0 -> PInvoke.User32.MsgWaitForMultipleObjectsExFlags
PInvoke.User32.SafeCursorHandle
PInvoke.User32.SafeCursorHandle.SafeCursorHandle() -> void
PInvoke.User32.SafeCursorHandle.SafeCursorHandle(System.IntPtr preexistingHandle, bool ownsHandle = true) -> void
Expand All @@ -124,6 +129,21 @@ PInvoke.User32.SendMessageTimeoutFlags.SMTO_BLOCK = 1 -> PInvoke.User32.SendMess
PInvoke.User32.SendMessageTimeoutFlags.SMTO_ERRORONEXIT = 32 -> PInvoke.User32.SendMessageTimeoutFlags
PInvoke.User32.SendMessageTimeoutFlags.SMTO_NORMAL = 0 -> PInvoke.User32.SendMessageTimeoutFlags
PInvoke.User32.SendMessageTimeoutFlags.SMTO_NOTIMEOUTIFNOTHUNG = 8 -> PInvoke.User32.SendMessageTimeoutFlags
PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_ALLEVENTS = PInvoke.User32.WakeMask.QS_POSTMESSAGE | PInvoke.User32.WakeMask.QS_TIMER | PInvoke.User32.WakeMask.QS_PAINT | PInvoke.User32.WakeMask.QS_HOTKEY | PInvoke.User32.WakeMask.QS_INPUT -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_ALLINPUT = PInvoke.User32.WakeMask.QS_SENDMESSAGE | PInvoke.User32.WakeMask.QS_ALLEVENTS -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_ALLPOSTMESSAGE = 256 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_HOTKEY = 128 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_INPUT = PInvoke.User32.WakeMask.QS_KEY | PInvoke.User32.WakeMask.QS_MOUSE | PInvoke.User32.WakeMask.QS_RAWINPUT -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_KEY = 1 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_MOUSE = PInvoke.User32.WakeMask.QS_MOUSEMOVE | PInvoke.User32.WakeMask.QS_MOUSEBUTTON -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_MOUSEBUTTON = 4 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_MOUSEMOVE = 2 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_PAINT = 32 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_POSTMESSAGE = 8 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_RAWINPUT = 1024 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_SENDMESSAGE = 64 -> PInvoke.User32.WakeMask
PInvoke.User32.WakeMask.QS_TIMER = 16 -> PInvoke.User32.WakeMask
PInvoke.User32.WindowLongIndexFlags.GWLP_ID = PInvoke.User32.WindowLongIndexFlags.GWL_STYLE | PInvoke.User32.WindowLongIndexFlags.DWLP_DLGPROC -> PInvoke.User32.WindowLongIndexFlags
PInvoke.User32.WindowLongIndexFlags.GWLP_USERDATA = -21 -> PInvoke.User32.WindowLongIndexFlags
PInvoke.User32.WindowLongIndexFlags.GWLP_WNDPROC = PInvoke.User32.WindowLongIndexFlags.GWL_STYLE | PInvoke.User32.WindowLongIndexFlags.DWLP_DLGPROC | PInvoke.User32.WindowLongIndexFlags.DWLP_USER -> PInvoke.User32.WindowLongIndexFlags
Expand All @@ -143,6 +163,14 @@ PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_RIGHTUP = 16 -> PInvoke.User32.mouse
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_WHEEL = 2048 -> PInvoke.User32.mouse_eventFlags
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_XDOWN = 128 -> PInvoke.User32.mouse_eventFlags
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_XUP = 256 -> PInvoke.User32.mouse_eventFlags
const PInvoke.User32.STATUS_ABANDONED_WAIT_0 = 128 -> uint
const PInvoke.User32.STATUS_USER_APC = 192 -> uint
const PInvoke.User32.STATUS_WAIT_0 = 0 -> uint
const PInvoke.User32.WAIT_ABANDONED_0 = 128 -> uint
const PInvoke.User32.WAIT_FAILED = 4294967295 -> uint
const PInvoke.User32.WAIT_IO_COMPLETION = 192 -> uint
const PInvoke.User32.WAIT_OBJECT_0 = 0 -> uint
const PInvoke.User32.WAIT_TIMEOUT = 258 -> uint
override PInvoke.User32.SafeCursorHandle.IsInvalid.get -> bool
override PInvoke.User32.SafeCursorHandle.ReleaseHandle() -> bool
static PInvoke.User32.AdjustWindowRectEx(System.IntPtr lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle) -> bool
Expand All @@ -167,6 +195,8 @@ static PInvoke.User32.LoadCursor(System.IntPtr hInstance, char[] lpCursorName) -
static PInvoke.User32.LoadImage(System.IntPtr hInst, System.IntPtr name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
static PInvoke.User32.LoadImage(System.IntPtr hInst, char[] name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
static PInvoke.User32.MENUBARINFO.Create() -> PInvoke.User32.MENUBARINFO
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr[] pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO lpmii) -> bool
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, System.IntPtr lpmii) -> bool
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, System.IntPtr dwNewLong) -> System.IntPtr
Expand Down Expand Up @@ -210,6 +240,7 @@ static extern PInvoke.User32.GetWindowDpiHostingBehavior(System.IntPtr hwnd) ->
static extern PInvoke.User32.IsValidDpiAwarenessContext(System.IntPtr dpiAwarenessContext) -> bool
static extern PInvoke.User32.LoadCursor(System.IntPtr hInstance, char* lpCursorName) -> PInvoke.User32.SafeCursorHandle
static extern PInvoke.User32.LoadImage(System.IntPtr hInst, char* name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
static extern PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr* pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
static extern PInvoke.User32.SendMessageTimeout(System.IntPtr hWnd, PInvoke.User32.WindowMessage msg, System.IntPtr wParam, System.IntPtr lParam, PInvoke.User32.SendMessageTimeoutFlags flags, int timeout, out System.IntPtr pdwResult) -> System.IntPtr
static extern PInvoke.User32.SetCursor(PInvoke.User32.SafeCursorHandle hCursor) -> PInvoke.User32.SafeCursorHandle
static extern PInvoke.User32.SetDialogControlDpiChangeBehavior(System.IntPtr hwnd, PInvoke.User32.DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS mask, PInvoke.User32.DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS values) -> bool
Expand Down
38 changes: 38 additions & 0 deletions src/User32/User32+MsgWaitForMultipleObjectsExFlags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace PInvoke
{
using System;

/// <content>Contains the <see cref="MsgWaitForMultipleObjectsExFlags" /> nested type.</content>
public partial class User32
{
/// <summary>
/// Flags for the <see cref="MsgWaitForMultipleObjectsEx(uint, IntPtr, uint, WakeMask, MsgWaitForMultipleObjectsExFlags)"/> method.
/// </summary>
[Flags]
public enum MsgWaitForMultipleObjectsExFlags : uint
{
/// <summary>
/// The function returns when any one of the objects is signaled. The return value indicates the object whose state caused the function to return.
/// </summary>
None,

/// <summary>
/// The function returns when all objects in the pHandles array are signaled and an input event has been received, all at the same time.
/// </summary>
MWMO_WAITALL = 0x0001,

/// <summary>
/// The function also returns if an APC has been queued to the thread with QueueUserAPC while the thread is in the waiting state.
/// </summary>
MWMO_ALERTABLE = 0x0002,

/// <summary>
/// The function returns if input exists for the queue, even if the input has been seen (but not removed) using a call to another function, such as <see cref="PeekMessage(MSG*, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)"/>.
/// </summary>
MWMO_INPUTAVAILABLE = 0x0004,
}
}
}
94 changes: 94 additions & 0 deletions src/User32/User32+WakeMask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace PInvoke
{
using System;

/// <content>Contains the <see cref="WakeMask" /> nested type.</content>
public partial class User32
{
/// <summary>
/// The mask passed to <see cref="MsgWaitForMultipleObjectsEx(uint, IntPtr, uint, WakeMask, MsgWaitForMultipleObjectsExFlags)"/>.
/// </summary>
[Flags]
public enum WakeMask : uint
{
/// <summary>
/// An input, <see cref="WindowMessage.WM_TIMER" />, <see cref="WindowMessage.WM_PAINT" />, <see cref="WindowMessage.WM_HOTKEY" />, or posted message is in the queue.
/// This value is a combination of <see cref="QS_INPUT" />, <see cref="QS_POSTMESSAGE" />, <see cref="QS_TIMER" />, <see cref="QS_PAINT" />, and <see cref="QS_HOTKEY" />.
/// </summary>
QS_ALLEVENTS = 0x04BF,

/// <summary>
/// Any message is in the queue.
/// This value is a combination of <see cref="QS_INPUT" />, <see cref="QS_POSTMESSAGE" />, <see cref="QS_TIMER" />, <see cref="QS_PAINT" />, <see cref="QS_HOTKEY" />, and <see cref="QS_SENDMESSAGE" />.
/// </summary>
QS_ALLINPUT = 0x04FF,

/// <summary>
/// A posted message is in the queue.
/// This value is cleared when you call <see cref="GetMessage(MSG*, IntPtr, WindowMessage, WindowMessage)"/> or <see cref="PeekMessage(MSG*, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)"/> without filtering messages.
/// </summary>
QS_ALLPOSTMESSAGE = 0x0100,

/// <summary>
/// A <see cref="WindowMessage.WM_HOTKEY"/> message is in the queue.
/// </summary>
QS_HOTKEY = 0x0080,

/// <summary>
/// An input message is in the queue.
/// This value is a combination of <see cref="QS_MOUSE" />, <see cref="QS_KEY" />, and <see cref="QS_RAWINPUT" />.
/// </summary>
QS_INPUT = 0x0407,

/// <summary>
/// A <see cref="WindowMessage.WM_KEYUP" />, <see cref="WindowMessage.WM_KEYDOWN" />, <see cref="WindowMessage.WM_SYSKEYUP" />, or <see cref="WindowMessage.WM_SYSKEYDOWN " />message is in the queue.
/// </summary>
QS_KEY = 0x0001,

/// <summary>
/// A <see cref="WindowMessage.WM_MOUSEMOVE"/> message or mouse-button message (<see cref="WindowMessage.WM_LBUTTONUP"/>, <see cref="WindowMessage.WM_RBUTTONDOWN"/>, and so on).
/// This value is a combination of <see cref="QS_MOUSEMOVE"/> and <see cref="QS_MOUSEBUTTON"/>.
/// </summary>
QS_MOUSE = QS_MOUSEMOVE | QS_MOUSEBUTTON,

/// <summary>
/// A mouse-button message (<see cref="WindowMessage.WM_LBUTTONUP"/>, <see cref="WindowMessage.WM_RBUTTONDOWN"/>, and so on).
/// </summary>
QS_MOUSEBUTTON = 0x0004,

/// <summary>
/// A <see cref="WindowMessage.WM_MOUSEMOVE"/> message is in the queue.
/// </summary>
QS_MOUSEMOVE = 0x0002,

/// <summary>
/// A <see cref="WindowMessage.WM_PAINT"/> message is in the queue.
/// </summary>
QS_PAINT = 0x0020,

/// <summary>
/// A posted message is in the queue.
/// This value is cleared when you call <see cref="GetMessage(MSG*, IntPtr, WindowMessage, WindowMessage)"/> or <see cref="PeekMessage(MSG*, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)"/>, whether or not you are filtering messages.
/// </summary>
QS_POSTMESSAGE = 0x0008,

/// <summary>
/// A raw input message is in the queue. For more information, see Raw Input.
/// </summary>
QS_RAWINPUT = 0x0400,

/// <summary>
/// A message sent by another thread or application is in the queue.
/// </summary>
QS_SENDMESSAGE = 0x0040,

/// <summary>
/// A <see cref="WindowMessage.WM_TIMER"/> message is in the queue.
/// </summary>
QS_TIMER = 0x0010,
}
}
}
49 changes: 48 additions & 1 deletion src/User32/User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace PInvoke
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
using PInvoke;
using static PInvoke.Kernel32;

Expand Down Expand Up @@ -46,6 +47,22 @@ public static partial class User32
/// </summary>
public const int LF_FACESIZE = 32;

public const uint STATUS_WAIT_0 = 0;

public const uint WAIT_OBJECT_0 = STATUS_WAIT_0 + 0;

public const uint STATUS_ABANDONED_WAIT_0 = 0x80;

public const uint WAIT_ABANDONED_0 = STATUS_ABANDONED_WAIT_0 + 0;

public const uint STATUS_USER_APC = 0x000000C0;

public const uint WAIT_IO_COMPLETION = STATUS_USER_APC;

public const uint WAIT_TIMEOUT = 258;

public const uint WAIT_FAILED = 0xFFFFFFFF;

/// <summary>
/// A bitmap that is drawn by the window that owns the menu. The application must process the WM_MEASUREITEM and
/// WM_DRAWITEM messages.
Expand Down Expand Up @@ -1731,7 +1748,7 @@ public static extern unsafe uint SendInput(
/// </summary>
/// <param name="hProcess">A handle to the process. If this process is a console application or does not have a message queue, WaitForInputIdle returns immediately.</param>
/// <param name="dwMilliseconds">The time-out interval, in milliseconds. If dwMilliseconds is INFINITE, the function does not return until the process is idle.</param>
/// <returns>0 if the wait was satisfied successfully., WAIT_TIMEOUT if the wait was terminated because the time-out interval elapsed, and WAIT_FAILED if an error occurred.</returns>
/// <returns>0 if the wait was satisfied successfully., <see cref="WAIT_TIMEOUT" /> if the wait was terminated because the time-out interval elapsed, and <see cref="WAIT_FAILED"/> if an error occurred.</returns>
/// <remarks>Raymond Chen has a series of articles that give a bit more depth to how this function was intended to be used.
/// <a href="http://blogs.msdn.com/b/oldnewthing/archive/2010/03/25/9984720.aspx">Here</a> and <a href="http://blogs.msdn.com/b/oldnewthing/archive/2010/03/26/9985422.aspx">here</a>.
/// The jist of it is that this function should have been really called WaitForProcessStartupComplete, as this is all it does.</remarks>
Expand Down Expand Up @@ -3692,6 +3709,36 @@ public static extern unsafe bool AdjustWindowRectEx(
[MarshalAs(UnmanagedType.Bool)] bool bMenu,
WindowStylesEx dwExStyle);

/// <summary>
/// Waits until one or all of the specified objects are in the signaled state,
/// an I/O completion routine or asynchronous procedure call (APC) is queued to the thread,
/// or the time-out interval elapses. The array of objects can include input event objects,
/// which you specify using the <paramref name="dwWakeMask"/> parameter.
/// </summary>
/// <param name="nCount">The number of object handles in the array pointed to by pHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS minus one. If this parameter has the value zero, then the function waits only for an input event.</param>
/// <param name="pHandles">
/// An array of object handles. For a list of the object types whose handles you can specify, see the Remarks section later in this topic. The array can contain handles to multiple types of objects. It may not contain multiple copies of the same handle.
/// If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
/// The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
/// </param>
/// <param name="dwMilliseconds">
/// The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled,
/// an I/O completion routine or APC is queued, or the interval elapses.
/// If dwMilliseconds is zero, the function does not enter a wait state if the criteria is not met; it always returns immediately.
/// If dwMilliseconds is <see cref="Timeout.Infinite"/>, the function will return only when the specified objects are signaled or
/// an I/O completion routine or APC is queued.
/// </param>
/// <param name="dwWakeMask">The input types for which an input event object handle will be added to the array of object handles.</param>
/// <param name="dwFlags">The wait type.</param>
/// <returns>If the function succeeds, the return value indicates the event that caused the function to return. See docs for values.</returns>
[DllImport(nameof(User32), SetLastError = true)]
public static unsafe extern uint MsgWaitForMultipleObjectsEx(
uint nCount,
[Friendly(FriendlyFlags.In | FriendlyFlags.Array)] IntPtr* pHandles,
uint dwMilliseconds,
WakeMask dwWakeMask,
MsgWaitForMultipleObjectsExFlags dwFlags);

/// <summary>
/// The BeginPaint function prepares the specified window for painting and fills a <see cref="PAINTSTRUCT"/> structure with information about the painting.
/// </summary>
Expand Down