|
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
/// <content>
/// Contains extern methods from "USER32.dll".
/// </content>
internal static partial class PInvoke
{
/// <summary>Unloads an input locale identifier (formerly called a keyboard layout).</summary>
/// <param name="hkl">
/// <para>Type: <b>HKL</b> The input locale identifier to be unloaded.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-unloadkeyboardlayout#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. The function can fail for the following reasons: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input. <b>UnloadKeyboardLayout</b> cannot unload the system default input locale identifier if it is the only keyboard layout loaded. You must first load another input locale identifier before unloading the default input locale identifier.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-unloadkeyboardlayout#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL UnloadKeyboardLayout(winmdroot.UI.Input.KeyboardAndMouse.HKL hkl)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hkl);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "UnloadKeyboardLayout"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.Input.KeyboardAndMouse.HKL hkl);
}
/// <summary>Sets the input locale identifier (formerly called the keyboard layout handle) for the calling thread or the current process. The input locale identifier specifies a locale as well as the physical layout of the keyboard.</summary>
/// <param name="hkl">
/// <para>Type: <b>HKL</b> Input locale identifier to be activated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-activatekeyboardlayout#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Flags">Type: <b>UINT</b></param>
/// <returns>
/// <para>Type: <b>HKL</b> The return value is of type <b>HKL</b>. If the function succeeds, the return value is the previous input locale identifier. Otherwise, it is zero. To get extended error information, use the <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> function.</para>
/// </returns>
/// <remarks>
/// <para>This function only affects the layout for the current process or thread. This function is not restricted to keyboard layouts. The <i>hkl</i> parameter is actually an input locale identifier. This is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input. Several input locale identifiers can be loaded at any one time, but only one is active at a time. Loading multiple input locale identifiers makes it possible to rapidly switch between them. When multiple IMEs are allowed for each locale, passing an input locale identifier in which the high word (the device handle) is zero activates the first IME in the list belonging to the locale. The <b>KLF_RESET</b> and <b>KLF_SHIFTLOCK</b> flags alter the method by which the Caps Lock state is turned off. By default, the Caps Lock state is turned off by hitting the Caps Lock key again. If only <b>KLF_RESET</b> is set, the default state is reestablished. If <b>KLF_RESET</b> and <b>KLF_SHIFTLOCK</b> are set, the Caps Lock state is turned off by pressing either Caps Lock key. This feature is used to conform to local keyboard behavior standards as well as for personal preferences.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-activatekeyboardlayout#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.UI.Input.KeyboardAndMouse.HKL ActivateKeyboardLayout(winmdroot.UI.Input.KeyboardAndMouse.HKL hkl, winmdroot.UI.Input.KeyboardAndMouse.ACTIVATE_KEYBOARD_LAYOUT_FLAGS Flags)
{
Marshal.SetLastSystemError(0);
winmdroot.UI.Input.KeyboardAndMouse.HKL __retVal = LocalExternFunction(hkl, Flags);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ActivateKeyboardLayout"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.UI.Input.KeyboardAndMouse.HKL LocalExternFunction(winmdroot.UI.Input.KeyboardAndMouse.HKL hkl, winmdroot.UI.Input.KeyboardAndMouse.ACTIVATE_KEYBOARD_LAYOUT_FLAGS Flags);
}
/// <inheritdoc cref="AdjustWindowRectEx(winmdroot.Foundation.RECT*, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE, winmdroot.Foundation.BOOL, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL AdjustWindowRectEx(ref winmdroot.Foundation.RECT lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle)
{
fixed (winmdroot.Foundation.RECT* lpRectLocal = &lpRect)
{
winmdroot.Foundation.BOOL __result = PInvoke.AdjustWindowRectEx(lpRectLocal, dwStyle, bMenu, dwExStyle);
return __result;
}
}
/// <summary>Calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area is the desired size.</summary>
/// <param name="lpRect">
/// <para>Type: <b>LPRECT</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-adjustwindowrectex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwStyle">
/// <para>Type: <b>DWORD</b> The <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-styles">window style</a> of the window whose required size is to be calculated. Note that you cannot specify the <b>WS_OVERLAPPED</b> style.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-adjustwindowrectex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bMenu">
/// <para>Type: <b>BOOL</b> Indicates whether the window has a menu.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-adjustwindowrectex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwExStyle">
/// <para>Type: <b>DWORD</b> The <a href="https://docs.microsoft.com/windows/desktop/winmsg/extended-window-styles">extended window style</a> of the window whose required size is to be calculated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-adjustwindowrectex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>A client rectangle is the smallest rectangle that completely encloses a client area. A window rectangle is the smallest rectangle that completely encloses the window, which includes the client area and the nonclient area. The <b>AdjustWindowRectEx</b> function does not add extra space when a menu bar wraps to two or more rows. The <b>AdjustWindowRectEx</b> function does not take the <b>WS_VSCROLL</b> or <b>WS_HSCROLL</b> styles into account. To account for the scroll bars, call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getsystemmetrics">GetSystemMetrics</a> function with <b>SM_CXVSCROLL</b> or <b>SM_CYHSCROLL</b>. This API is not DPI aware, and should not be used if the calling thread is per-monitor DPI aware. For the DPI-aware version of this API, see <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-adjustwindowrectexfordpi">AdjustWindowsRectExForDPI</a>. For more information on DPI awareness, see <a href="https://docs.microsoft.com/windows/desktop/hidpi/high-dpi-desktop-application-development-on-windows">the Windows High DPI documentation.</a></para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-adjustwindowrectex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL AdjustWindowRectEx(winmdroot.Foundation.RECT* lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpRect, dwStyle, bMenu, dwExStyle);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "AdjustWindowRectEx"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.RECT* lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle);
}
/// <inheritdoc cref="AdjustWindowRectExForDpi(winmdroot.Foundation.RECT*, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE, winmdroot.Foundation.BOOL, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE, uint)"/>
[SupportedOSPlatform("windows10.0.14393")]
internal static unsafe winmdroot.Foundation.BOOL AdjustWindowRectExForDpi(ref winmdroot.Foundation.RECT lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, uint dpi)
{
fixed (winmdroot.Foundation.RECT* lpRectLocal = &lpRect)
{
winmdroot.Foundation.BOOL __result = PInvoke.AdjustWindowRectExForDpi(lpRectLocal, dwStyle, bMenu, dwExStyle, dpi);
return __result;
}
}
/// <summary>Calculates the required size of the window rectangle, based on the desired size of the client rectangle and the provided DPI.</summary>
/// <param name="lpRect">A pointer to a <b>RECT</b> structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.</param>
/// <param name="dwStyle">The <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-styles">Window Style</a> of the window whose required size is to be calculated. Note that you cannot specify the <b>WS_OVERLAPPED</b> style.</param>
/// <param name="bMenu">Indicates whether the window has a menu.</param>
/// <param name="dwExStyle">The <a href="https://docs.microsoft.com/windows/desktop/winmsg/extended-window-styles">Extended Window Style</a> of the window whose required size is to be calculated.</param>
/// <param name="dpi">The DPI to use for scaling.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>This function returns the same result as <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-adjustwindowrectex">AdjustWindowRectEx</a> but scales it according to an arbitrary DPI you provide if appropriate.</remarks>
[SupportedOSPlatform("windows10.0.14393")]
internal static unsafe winmdroot.Foundation.BOOL AdjustWindowRectExForDpi(winmdroot.Foundation.RECT* lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, uint dpi)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpRect, dwStyle, bMenu, dwExStyle, dpi);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "AdjustWindowRectExForDpi"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.RECT* lpRect, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, winmdroot.Foundation.BOOL bMenu, winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, uint dpi);
}
/// <summary>Determines whether two DPI_AWARENESS_CONTEXT values are identical.</summary>
/// <param name="dpiContextA">The first value to compare.</param>
/// <param name="dpiContextB">The second value to compare.</param>
/// <returns>Returns <b>TRUE</b> if the values are equal, otherwise <b>FALSE</b>.</returns>
/// <remarks>A <b>DPI_AWARENESS_CONTEXT</b> contains multiple pieces of information. For example, it includes both the current and the inherited <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a> values. <b>AreDpiAwarenessContextsEqual</b> ignores informational flags and determines if the values are equal. You can't use a direct bitwise comparison because of these informational flags.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.Foundation.BOOL AreDpiAwarenessContextsEqual(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT dpiContextA, winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT dpiContextB);
/// <summary>Blocks keyboard and mouse input events from reaching applications.</summary>
/// <param name="fBlockIt">
/// <para>Type: <b>BOOL</b> The function's purpose. If this parameter is <b>TRUE</b>, keyboard and mouse input events are blocked. If this parameter is <b>FALSE</b>, keyboard and mouse events are unblocked. Note that only the thread that blocked input can successfully unblock input.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-blockinput#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If input is already blocked, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>When input is blocked, real physical input from the mouse or keyboard will not affect the input queue's synchronous key state (reported by <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeystate">GetKeyState</a> and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeyboardstate">GetKeyboardState</a>), nor will it affect the asynchronous key state (reported by <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getasynckeystate">GetAsyncKeyState</a>). However, the thread that is blocking input can affect both of these key states by calling <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendinput">SendInput</a>. No other thread can do this. The system will unblock input in the following cases: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-blockinput#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL BlockInput(winmdroot.Foundation.BOOL fBlockIt)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(fBlockIt);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "BlockInput"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.BOOL fBlockIt);
}
/// <summary>Removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.</summary>
/// <param name="hhk">
/// <para>Type: <b>HHOOK</b> A handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowshookexa">SetWindowsHookEx</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-unhookwindowshookex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>The hook procedure can be in the state of being called by another thread even after <b>UnhookWindowsHookEx</b> returns. If the hook procedure is not being called concurrently, the hook procedure is removed immediately before <b>UnhookWindowsHookEx</b> returns.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL UnhookWindowsHookEx(winmdroot.UI.WindowsAndMessaging.HHOOK hhk)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hhk);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "UnhookWindowsHookEx"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.HHOOK hhk);
}
/// <summary>Passes the hook information to the next hook procedure in the current hook chain. A hook procedure can call this function either before or after processing the hook information.</summary>
/// <param name="hhk">
/// <para>Type: <b>HHOOK</b> This parameter is ignored.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-callnexthookex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nCode">
/// <para>Type: <b>int</b> The hook code passed to the current hook procedure. The next hook procedure uses this code to determine how to process the hook information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-callnexthookex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> The <i>wParam</i> value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-callnexthookex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> The <i>lParam</i> value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-callnexthookex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> This value is returned by the next hook procedure in the chain. The current hook procedure must also return this value. The meaning of the return value depends on the hook type. For more information, see the descriptions of the individual hook procedures.</para>
/// </returns>
/// <remarks>
/// <para>Hook procedures are installed in chains for particular hook types. <b>CallNextHookEx</b> calls the next hook in the chain. Calling <b>CallNextHookEx</b> is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call <b>CallNextHookEx</b> unless you absolutely need to prevent the notification from being seen by other applications.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-callnexthookex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.LRESULT CallNextHookEx(winmdroot.UI.WindowsAndMessaging.HHOOK hhk, int nCode, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam);
/// <summary>Determines which, if any, of the child windows belonging to the specified parent window contains the specified point.</summary>
/// <param name="hwnd">
/// <para>Type: <b>HWND</b> A handle to the parent window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-childwindowfrompointex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pt">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a></b> A structure that defines the client coordinates (relative to <i>hwndParent</i>) of the point to be checked.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-childwindowfrompointex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="flags">
/// <para>Type: <b>UINT</b> The child windows to be skipped. This parameter can be one or more of the following values. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-childwindowfrompointex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is a handle to the first child window that contains the point and meets the criteria specified by <i>uFlags</i>. If the point is within the parent window but not within any child window that meets the criteria, the return value is a handle to the parent window. If the point lies outside the parent window or if the function fails, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>The system maintains an internal list that contains the handles of the child windows associated with a parent window. The order of the handles in the list depends on the Z order of the child windows. If more than one child window contains the specified point, the system returns a handle to the first window in the list that contains the point and meets the criteria specified by <i>uFlags</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-childwindowfrompointex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND ChildWindowFromPointEx(winmdroot.Foundation.HWND hwnd, global::System.Drawing.Point pt, winmdroot.UI.WindowsAndMessaging.CWP_FLAGS flags);
/// <inheritdoc cref="ClientToScreen(winmdroot.Foundation.HWND, global::System.Drawing.Point*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL ClientToScreen(winmdroot.Foundation.HWND hWnd, ref global::System.Drawing.Point lpPoint)
{
fixed (global::System.Drawing.Point* lpPointLocal = &lpPoint)
{
winmdroot.Foundation.BOOL __result = PInvoke.ClientToScreen(hWnd, lpPointLocal);
return __result;
}
}
/// <summary>The ClientToScreen function converts the client-area coordinates of a specified point to screen coordinates.</summary>
/// <param name="hWnd">A handle to the window whose client area is used for the conversion.</param>
/// <param name="lpPoint">A pointer to a <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure that contains the client coordinates to be converted. The new screen coordinates are copied into this structure if the function succeeds.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <b>ClientToScreen</b> function replaces the client-area coordinates in the <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure with the screen coordinates. The screen coordinates are relative to the upper-left corner of the screen. Note, a screen-coordinate point that is above the window's client area has a negative y-coordinate. Similarly, a screen coordinate to the left of a client area has a negative x-coordinate. All coordinates are device coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-clienttoscreen#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL ClientToScreen(winmdroot.Foundation.HWND hWnd, global::System.Drawing.Point* lpPoint);
/// <inheritdoc cref="ClipCursor(winmdroot.Foundation.RECT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL ClipCursor(winmdroot.Foundation.RECT? lpRect)
{
winmdroot.Foundation.RECT lpRectLocal = lpRect ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.BOOL __result = PInvoke.ClipCursor(lpRect.HasValue ? &lpRectLocal : null);
return __result;
}
/// <summary>Confines the cursor to a rectangular area on the screen.</summary>
/// <param name="lpRect">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a>*</b> A pointer to the structure that contains the screen coordinates of the upper-left and lower-right corners of the confining rectangle. If this parameter is <b>NULL</b>, the cursor is free to move anywhere on the screen.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-clipcursor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The cursor is a shared resource. If an application confines the cursor, it must release the cursor by using <b>ClipCursor</b> before relinquishing control to another application. The calling process must have <b>WINSTA_WRITEATTRIBUTES</b> access to the window station.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-clipcursor#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL ClipCursor([Optional] winmdroot.Foundation.RECT* lpRect)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpRect);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ClipCursor"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction([Optional] winmdroot.Foundation.RECT* lpRect);
}
/// <summary>Closes an open handle to a desktop object.</summary>
/// <param name="hDesktop">
/// <para>A handle to the desktop to be closed. This can be a handle returned by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createdesktopa">CreateDesktop</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-opendesktopa">OpenDesktop</a>, or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-openinputdesktop">OpenInputDesktop</a> functions. Do not specify the handle returned by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getthreaddesktop">GetThreadDesktop</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-closedesktop#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>CloseDesktop</b> function will fail if any thread in the calling process is using the specified desktop handle or if the handle refers to the initial desktop of the calling process.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-closedesktop#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL CloseDesktop(winmdroot.System.StationsAndDesktops.HDESK hDesktop)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hDesktop);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "CloseDesktop"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.System.StationsAndDesktops.HDESK hDesktop);
}
/// <summary>Destroys an accelerator table.</summary>
/// <param name="hAccel">
/// <para>Type: <b>HACCEL</b> A handle to the accelerator table to be destroyed. This handle must have been created by a call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createacceleratortablea">CreateAcceleratorTable</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-loadacceleratorsa">LoadAccelerators</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroyacceleratortable#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. However, if the table has been loaded more than one call to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-loadacceleratorsa">LoadAccelerators</a>, the function will return a nonzero value only when <b>DestroyAcceleratorTable</b> has been called an equal number of times. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroyacceleratortable">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL DestroyAcceleratorTable(winmdroot.UI.WindowsAndMessaging.HACCEL hAccel);
/// <inheritdoc cref="CreateAcceleratorTable(winmdroot.UI.WindowsAndMessaging.ACCEL*, int)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.UI.WindowsAndMessaging.HACCEL CreateAcceleratorTable(ReadOnlySpan<winmdroot.UI.WindowsAndMessaging.ACCEL> paccel)
{
fixed (winmdroot.UI.WindowsAndMessaging.ACCEL* paccelLocal = paccel)
{
winmdroot.UI.WindowsAndMessaging.HACCEL __result = PInvoke.CreateAcceleratorTable(paccelLocal, paccel.Length);
return __result;
}
}
/// <summary>Creates an accelerator table. (Unicode)</summary>
/// <param name="paccel">
/// <para>Type: <b>LPACCEL</b> An array of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-accel">ACCEL</a> structures that describes the accelerator table.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createacceleratortablew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cAccel">
/// <para>Type: <b>int</b> The number of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-accel">ACCEL</a> structures in the array. This must be within the range 1 to 32767 or the function will fail.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createacceleratortablew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HACCEL</b> If the function succeeds, the return value is the handle to the created accelerator table; otherwise, it is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>Before an application closes, it can use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-destroyacceleratortable">DestroyAcceleratorTable</a> function to destroy any accelerator tables that it created by using the <b>CreateAcceleratorTable</b> function.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.UI.WindowsAndMessaging.HACCEL CreateAcceleratorTable(winmdroot.UI.WindowsAndMessaging.ACCEL* paccel, int cAccel)
{
Marshal.SetLastSystemError(0);
winmdroot.UI.WindowsAndMessaging.HACCEL __retVal = LocalExternFunction(paccel, cAccel);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "CreateAcceleratorTableW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.UI.WindowsAndMessaging.HACCEL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.ACCEL* paccel, int cAccel);
}
/// <summary>Destroys the specified menu and frees any memory that the menu occupies.</summary>
/// <param name="hMenu">
/// <para>Type: <b>HMENU</b> A handle to the menu to be destroyed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroymenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>Before closing, an application must use the <b>DestroyMenu</b> function to destroy a menu not assigned to a window. A menu that is assigned to a window is automatically destroyed when the application closes. <b>DestroyMenu</b> is recursive, that is, it will destroy the menu and all its submenus.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroymenu#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL DestroyMenu(winmdroot.UI.WindowsAndMessaging.HMENU hMenu)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hMenu);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DestroyMenu"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.HMENU hMenu);
}
/// <summary>Creates a menu. The menu is initially empty, but it can be filled with menu items by using the InsertMenuItem, AppendMenu, and InsertMenu functions.</summary>
/// <returns>
/// <para>Type: <b>HMENU</b> If the function succeeds, the return value is a handle to the newly created menu. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>Resources associated with a menu that is assigned to a window are freed automatically. If the menu is not assigned to a window, an application must free system resources associated with the menu before closing. An application frees menu resources by calling the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-destroymenu">DestroyMenu</a> function.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.UI.WindowsAndMessaging.HMENU CreateMenu()
{
Marshal.SetLastSystemError(0);
winmdroot.UI.WindowsAndMessaging.HMENU __retVal = LocalExternFunction();
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "CreateMenu"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.UI.WindowsAndMessaging.HMENU LocalExternFunction();
}
/// <inheritdoc cref="CreateWindowEx(winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE, int, int, int, int, winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.HMENU, winmdroot.Foundation.HINSTANCE, void*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.HWND CreateWindowEx(winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, string lpClassName, string lpWindowName, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, winmdroot.Foundation.HWND hWndParent, winmdroot.UI.WindowsAndMessaging.HMENU hMenu, winmdroot.Foundation.HINSTANCE hInstance, void* lpParam)
{
fixed (char* lpWindowNameLocal = lpWindowName)
{
fixed (char* lpClassNameLocal = lpClassName)
{
winmdroot.Foundation.HWND __result = PInvoke.CreateWindowEx(dwExStyle, lpClassNameLocal, lpWindowNameLocal, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
return __result;
}
}
}
/// <summary>Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function. (Unicode)</summary>
/// <param name="dwExStyle">
/// <para>Type: <b>DWORD</b> The extended window style of the window being created. For a list of possible values, see <a href="https://docs.microsoft.com/windows/desktop/winmsg/extended-window-styles">Extended Window Styles</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpClassName">
/// <para>Type: <b>LPCTSTR</b> A <b>null</b>-terminated string or a class atom created by a previous call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassexa">RegisterClassEx</a> function. The atom must be in the low-order word of <i>lpClassName</i>; the high-order word must be zero. If <i>lpClassName</i> is a string, it specifies the window class name. The class name can be any name registered with <b>RegisterClass</b> or <b>RegisterClassEx</b>, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined <a href="https://docs.microsoft.com/windows/desktop/winmsg/about-window-classes">system class</a> names.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpWindowName">
/// <para>Type: <b>LPCTSTR</b> The window name. If the window style specifies a title bar, the window title pointed to by <i>lpWindowName</i> is displayed in the title bar. When using <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowa">CreateWindow</a> to create controls, such as buttons, check boxes, and static controls, use <i>lpWindowName</i> to specify the text of the control. When creating a static control with the <b>SS_ICON</b> style, use <i>lpWindowName</i> to specify the icon name or identifier. To specify an identifier, use the syntax "#<i>num</i>".</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwStyle">
/// <para>Type: <b>DWORD</b> The style of the window being created. This parameter can be a combination of the <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-styles">window style values</a>, plus the control styles indicated in the Remarks section.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="X">
/// <para>Type: <b>int</b> The initial horizontal position of the window. For an overlapped or pop-up window, the <i>x</i> parameter is the initial x-coordinate of the window's upper-left corner, in screen coordinates. For a child window, <i>x</i> is the x-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area. If <i>x</i> is set to <b>CW_USEDEFAULT</b>, the system selects the default position for the window's upper-left corner and ignores the <i>y</i> parameter. <b>CW_USEDEFAULT</b> is valid only for overlapped windows; if it is specified for a pop-up or child window, the <i>x</i> and <i>y</i> parameters are set to zero.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Y">
/// <para>Type: <b>int</b> The initial vertical position of the window. For an overlapped or pop-up window, the <i>y</i> parameter is the initial y-coordinate of the window's upper-left corner, in screen coordinates. For a child window, <i>y</i> is the initial y-coordinate of the upper-left corner of the child window relative to the upper-left corner of the parent window's client area. For a list box <i>y</i> is the initial y-coordinate of the upper-left corner of the list box's client area relative to the upper-left corner of the parent window's client area.</para>
/// <para>If an overlapped window is created with the <b>WS_VISIBLE</b> style bit set and the <i>x</i> parameter is set to <b>CW_USEDEFAULT</b>, then the <i>y</i> parameter determines how the window is shown. If the <i>y</i> parameter is <b>CW_USEDEFAULT</b>, then the window manager calls <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-showwindow">ShowWindow</a> with the <b>SW_SHOW</b> flag after the window has been created. If the <i>y</i> parameter is some other value, then the window manager calls <b>ShowWindow</b> with that value as the <i>nCmdShow</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nWidth">
/// <para>Type: <b>int</b> The width, in device units, of the window. For overlapped windows, <i>nWidth</i> is the window's width, in screen coordinates, or <b>CW_USEDEFAULT</b>. If <i>nWidth</i> is <b>CW_USEDEFAULT</b>, the system selects a default width and height for the window; the default width extends from the initial x-coordinates to the right edge of the screen; the default height extends from the initial y-coordinate to the top of the icon area. <b>CW_USEDEFAULT</b> is valid only for overlapped windows; if <b>CW_USEDEFAULT</b> is specified for a pop-up or child window, the <i>nWidth</i> and <i>nHeight</i> parameter are set to zero.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nHeight">
/// <para>Type: <b>int</b> The height, in device units, of the window. For overlapped windows, <i>nHeight</i> is the window's height, in screen coordinates. If the <i>nWidth</i> parameter is set to <b>CW_USEDEFAULT</b>, the system ignores <i>nHeight</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWndParent">
/// <para>Type: <b>HWND</b> A handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows. To create a <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-features">message-only window</a>, supply <b>HWND_MESSAGE</b> or a handle to an existing message-only window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hMenu">
/// <para>Type: <b>HMENU</b> A handle to a menu, or specifies a child-window identifier, depending on the window style. For an overlapped or pop-up window, <i>hMenu</i> identifies the menu to be used with the window; it can be <b>NULL</b> if the class menu is to be used. For a child window, <i>hMenu</i> specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hInstance">
/// <para>Type: <b>HINSTANCE</b> A handle to the instance of the module to be associated with the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpParam">
/// <para>Type: <b>LPVOID</b> Pointer to a value to be passed to the window through the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-createstructa">CREATESTRUCT</a> structure (<b>lpCreateParams</b> member) pointed to by the <i>lParam</i> param of the <b>WM_CREATE</b> message. This message is sent to the created window by this function before it returns. If an application calls <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowa">CreateWindow</a> to create a MDI client window, <i>lpParam</i> should point to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-clientcreatestruct">CLIENTCREATESTRUCT</a> structure. If an MDI client window calls <b>CreateWindow</b> to create an MDI child window, <i>lpParam</i> should point to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-mdicreatestructa">MDICREATESTRUCT</a> structure. <i>lpParam</i> may be <b>NULL</b> if no additional data is needed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is a handle to the new window. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. This function typically fails for one of the following reasons: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The <b>CreateWindowEx</b> function sends <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-nccreate">WM_NCCREATE</a>, <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-nccalcsize">WM_NCCALCSIZE</a>, and <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-create">WM_CREATE</a> messages to the window being created. If the created window is a child window, its default position is at the bottom of the Z-order. If the created window is a top-level window, its default position is at the top of the Z-order (but beneath all topmost windows unless the created window is itself topmost). For information on controlling whether the Taskbar displays a button for the created window, see <a href="https://docs.microsoft.com/windows/desktop/shell/taskbar">Managing Taskbar Buttons</a>. For information on removing a window, see the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-destroywindow">DestroyWindow</a> function. The following predefined control classes can be specified in the <i>lpClassName</i> parameter. Note the corresponding control styles you can use in the <i>dwStyle</i> parameter. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.HWND CreateWindowEx(winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, winmdroot.Foundation.PCWSTR lpClassName, winmdroot.Foundation.PCWSTR lpWindowName, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, winmdroot.Foundation.HWND hWndParent, winmdroot.UI.WindowsAndMessaging.HMENU hMenu, winmdroot.Foundation.HINSTANCE hInstance, [Optional] void* lpParam)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "CreateWindowExW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.HWND LocalExternFunction(winmdroot.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, winmdroot.Foundation.PCWSTR lpClassName, winmdroot.Foundation.PCWSTR lpWindowName, winmdroot.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, winmdroot.Foundation.HWND hWndParent, winmdroot.UI.WindowsAndMessaging.HMENU hMenu, winmdroot.Foundation.HINSTANCE hInstance, [Optional] void* lpParam);
}
/// <summary>Provides default processing for any window messages that the window procedure of a multiple-document interface (MDI) frame window does not process. (Unicode)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the MDI frame window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWndMDIClient">
/// <para>Type: <b>HWND</b> A handle to the MDI client window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uMsg">
/// <para>Type: <b>UINT</b> The message to be processed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> The return value specifies the result of the message processing and depends on the message. If the <i>hWndMDIClient</i> parameter is <b>NULL</b>, the return value is the same as for the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-defwindowproca">DefWindowProc</a> function.</para>
/// </returns>
/// <remarks>
/// <para>When an application's window procedure does not handle a message, it typically passes the message to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-defwindowproca">DefWindowProc</a> function to process the message. MDI applications use the <b>DefFrameProc</b> and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-defmdichildproca">DefMDIChildProc</a> functions instead of <b>DefWindowProc</b> to provide default message processing. All messages that an application would usually pass to <b>DefWindowProc</b> (such as nonclient messages and the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-settext">WM_SETTEXT</a> message) should be passed to <b>DefFrameProc</b> instead. The <b>DefFrameProc</b> function also handles the following messages.</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defframeprocw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DefFrameProcW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.LRESULT DefFrameProc(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.HWND hWndMDIClient, uint uMsg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam);
/// <summary>Provides default processing for any window message that the window procedure of a multiple-document interface (MDI) child window does not process. (Unicode)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the MDI child window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defmdichildprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uMsg">
/// <para>Type: <b>UINT</b> The message to be processed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defmdichildprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defmdichildprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defmdichildprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> The return value specifies the result of the message processing and depends on the message.</para>
/// </returns>
/// <remarks>
/// <para>The <b>DefMDIChildProc</b> function assumes that the parent window of the MDI child window identified by the <i>hWnd</i> parameter was created with the <b>MDICLIENT</b> class. When an application's window procedure does not handle a message, it typically passes the message to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-defwindowproca">DefWindowProc</a> function to process the message. MDI applications use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-defframeproca">DefFrameProc</a> and <b>DefMDIChildProc</b> functions instead of <b>DefWindowProc</b> to provide default message processing. All messages that an application would usually pass to <b>DefWindowProc</b> (such as nonclient messages and the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-settext">WM_SETTEXT</a> message) should be passed to <b>DefMDIChildProc</b> instead. In addition, <b>DefMDIChildProc</b> also handles the following messages.</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-defmdichildprocw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DefMDIChildProcW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.LRESULT DefMDIChildProc(winmdroot.Foundation.HWND hWnd, uint uMsg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam);
/// <summary>Destroys a cursor and frees any memory the cursor occupied. Do not use this function to destroy a shared cursor.</summary>
/// <param name="hCursor">
/// <para>Type: <b>HCURSOR</b> A handle to the cursor to be destroyed. The cursor must not be in use.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroycursor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>DestroyCursor</b> function destroys a nonshared cursor. Do not use this function to destroy a shared cursor. A shared cursor is valid as long as the module from which it was loaded remains in memory. The following functions obtain a shared cursor: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroycursor#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL DestroyCursor(winmdroot.UI.WindowsAndMessaging.HCURSOR hCursor)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hCursor);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DestroyCursor"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.HCURSOR hCursor);
}
/// <summary>Destroys the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be destroyed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroywindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>A thread cannot use <b>DestroyWindow</b> to destroy a window created by a different thread. If the window being destroyed is a child window that does not have the <b>WS_EX_NOPARENTNOTIFY</b> style, a <a href="https://docs.microsoft.com/windows/win32/inputmsg/wm-parentnotify">WM_PARENTNOTIFY</a> message is sent to the parent.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-destroywindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL DestroyWindow(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DestroyWindow"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <inheritdoc cref="DispatchMessage(winmdroot.UI.WindowsAndMessaging.MSG*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.LRESULT DispatchMessage(in winmdroot.UI.WindowsAndMessaging.MSG lpMsg)
{
fixed (winmdroot.UI.WindowsAndMessaging.MSG* lpMsgLocal = &lpMsg)
{
winmdroot.Foundation.LRESULT __result = PInvoke.DispatchMessage(lpMsgLocal);
return __result;
}
}
/// <summary>Dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function. (DispatchMessageW)</summary>
/// <param name="lpMsg">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a>*</b> A pointer to a structure that contains the message.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-dispatchmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> The return value specifies the value returned by the window procedure. Although its meaning depends on the message being dispatched, the return value generally is ignored.</para>
/// </returns>
/// <remarks>
/// <para>The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure must contain valid message values. If the <i>lpmsg</i> parameter points to a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-timer">WM_TIMER</a> message and the <i>lParam</i> parameter of the <b>WM_TIMER</b> message is not <b>NULL</b>, <i>lParam</i> points to a function that is called instead of the window procedure. Note that the application is responsible for retrieving and dispatching input messages to the dialog box. Most applications use the main message loop for this. However, to permit the user to move to and to select controls by using the keyboard, the application must call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-isdialogmessagea">IsDialogMessage</a>. For more information, see <a href="https://docs.microsoft.com/windows/desktop/dlgbox/dlgbox-programming-considerations">Dialog Box Keyboard Interface</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-dispatchmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DispatchMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.LRESULT DispatchMessage(winmdroot.UI.WindowsAndMessaging.MSG* lpMsg);
/// <inheritdoc cref="DrawEdge(winmdroot.Graphics.Gdi.HDC, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.DRAWEDGE_FLAGS, winmdroot.Graphics.Gdi.DRAW_EDGE_FLAGS)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL DrawEdge(winmdroot.Graphics.Gdi.HDC hdc, ref winmdroot.Foundation.RECT qrc, winmdroot.Graphics.Gdi.DRAWEDGE_FLAGS edge, winmdroot.Graphics.Gdi.DRAW_EDGE_FLAGS grfFlags)
{
fixed (winmdroot.Foundation.RECT* qrcLocal = &qrc)
{
winmdroot.Foundation.BOOL __result = PInvoke.DrawEdge(hdc, qrcLocal, edge, grfFlags);
return __result;
}
}
/// <summary>The DrawEdge function draws one or more edges of rectangle.</summary>
/// <param name="hdc">A handle to the device context.</param>
/// <param name="qrc">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the logical coordinates of the rectangle.</param>
/// <param name="edge">
/// <para>The type of inner and outer edges to draw. This parameter must be a combination of one inner-border flag and one outer-border flag. The inner-border flags are as follows. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawedge#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="grfFlags"></param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawedge">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL DrawEdge(winmdroot.Graphics.Gdi.HDC hdc, winmdroot.Foundation.RECT* qrc, winmdroot.Graphics.Gdi.DRAWEDGE_FLAGS edge, winmdroot.Graphics.Gdi.DRAW_EDGE_FLAGS grfFlags);
/// <inheritdoc cref="DrawFrameControl(winmdroot.Graphics.Gdi.HDC, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.DFC_TYPE, winmdroot.Graphics.Gdi.DFCS_STATE)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL DrawFrameControl(winmdroot.Graphics.Gdi.HDC param0, ref winmdroot.Foundation.RECT param1, winmdroot.Graphics.Gdi.DFC_TYPE param2, winmdroot.Graphics.Gdi.DFCS_STATE param3)
{
fixed (winmdroot.Foundation.RECT* param1Local = ¶m1)
{
winmdroot.Foundation.BOOL __result = PInvoke.DrawFrameControl(param0, param1Local, param2, param3);
return __result;
}
}
/// <summary>The DrawFrameControl function draws a frame control of the specified type and style.</summary>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>If <i>uType</i> is either DFC_MENU or DFC_BUTTON and <i>uState</i> is not DFCS_BUTTONPUSH, the frame control is a black-on-white mask (that is, a black frame control on a white background). In such cases, the application must pass a handle to a bitmap memory device control. The application can then use the associated bitmap as the <i>hbmMask</i> parameter to the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-maskblt">MaskBlt</a> function, or it can use the device context as a parameter to the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-bitblt">BitBlt</a> function using ROPs such as SRCAND and SRCINVERT. <h3><a id="DPI_Virtualization"></a><a id="dpi_virtualization"></a><a id="DPI_VIRTUALIZATION"></a>DPI Virtualization</h3> This API does not participate in DPI virtualization. The input given is always in terms of physical pixels, and is not related to the calling context.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawframecontrol#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL DrawFrameControl(winmdroot.Graphics.Gdi.HDC param0, winmdroot.Foundation.RECT* param1, winmdroot.Graphics.Gdi.DFC_TYPE param2, winmdroot.Graphics.Gdi.DFCS_STATE param3);
/// <summary>Redraws the menu bar of the specified window. If the menu bar changes after the system has created the window, this function must be called to draw the changed menu bar.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose menu bar is to be redrawn.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawmenubar#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawmenubar">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL DrawMenuBar(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DrawMenuBar"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <inheritdoc cref="DrawText(winmdroot.Graphics.Gdi.HDC, winmdroot.Foundation.PCWSTR, int, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe int DrawText(winmdroot.Graphics.Gdi.HDC hdc, winmdroot.Foundation.PCWSTR lpchText, int cchText, ref winmdroot.Foundation.RECT lprc, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT format)
{
fixed (winmdroot.Foundation.RECT* lprcLocal = &lprc)
{
int __result = PInvoke.DrawText(hdc, lpchText, cchText, lprcLocal, format);
return __result;
}
}
/// <summary>The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth). (DrawTextW)</summary>
/// <param name="hdc">A handle to the device context.</param>
/// <param name="lpchText">
/// <para>A pointer to the string that specifies the text to be drawn. If the <i>nCount</i> parameter is -1, the string must be null-terminated. If <i>uFormat</i> includes DT_MODIFYSTRING, the function could add up to four additional characters to this string. The buffer containing the string should be large enough to accommodate these extra characters.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawtextw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cchText">The length, in characters, of the string. If <i>nCount</i> is -1, then the <i>lpchText</i> parameter is assumed to be a pointer to a null-terminated string and <b>DrawText</b> computes the character count automatically.</param>
/// <param name="lprc">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the rectangle (in logical coordinates) in which the text is to be formatted.</param>
/// <param name="format"></param>
/// <returns>
/// <para>If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from <c>lpRect->top</c> to the bottom of the drawn text If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <b>DrawText</b> function uses the device context's selected font, text color, and background color to draw the text. Unless the DT_NOCLIP format is used, <b>DrawText</b> clips the text so that it does not appear outside the specified rectangle. Note that text with significant overhang may be clipped, for example, an initial "W" in the text string or text that is in italics. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified. If the selected font is too large for the specified rectangle, the <b>DrawText</b> function does not attempt to substitute a smaller font. The text alignment mode for the device context must include the TA_LEFT, TA_TOP, and TA_NOUPDATECP flags.</para>
/// <para>> [!NOTE] > The winuser.h header defines DrawText as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawtextw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DrawTextW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe int DrawText(winmdroot.Graphics.Gdi.HDC hdc, winmdroot.Foundation.PCWSTR lpchText, int cchText, winmdroot.Foundation.RECT* lprc, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT format);
/// <inheritdoc cref="DrawTextEx(winmdroot.Graphics.Gdi.HDC, winmdroot.Foundation.PWSTR, int, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT, winmdroot.Graphics.Gdi.DRAWTEXTPARAMS*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe int DrawTextEx(winmdroot.Graphics.Gdi.HDC hdc, ref Span<char>lpchText, int cchText, ref winmdroot.Foundation.RECT lprc, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT format, winmdroot.Graphics.Gdi.DRAWTEXTPARAMS? lpdtp)
{
if (lpchText != null && lpchText.LastIndexOf('\0') == -1) throw new ArgumentException("Required null terminator missing.", "lpchText");
fixed (winmdroot.Foundation.RECT* lprcLocal = &lprc)
{
fixed (char* plpchText = lpchText)
{
winmdroot.Foundation.PWSTR wstrlpchText = plpchText;
winmdroot.Graphics.Gdi.DRAWTEXTPARAMS lpdtpLocal = lpdtp ?? default(winmdroot.Graphics.Gdi.DRAWTEXTPARAMS);
int __result = PInvoke.DrawTextEx(hdc, wstrlpchText, cchText, lprcLocal, format, lpdtp.HasValue ? &lpdtpLocal : null);
lpchText = lpchText.Slice(0, wstrlpchText.Length);
return __result;
}
}
}
/// <summary>The DrawTextEx function draws formatted text in the specified rectangle. (Unicode)</summary>
/// <param name="hdc">A handle to the device context in which to draw.</param>
/// <param name="lpchText">
/// <para>A pointer to the string that contains the text to draw. If the <i>cchText</i> parameter is -1, the string must be null-terminated. If <i>dwDTFormat</i> includes DT_MODIFYSTRING, the function could add up to four additional characters to this string. The buffer containing the string should be large enough to accommodate these extra characters.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawtextexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cchText">The <a href="https://docs.microsoft.com/windows/desktop/gdi/specifying-length-of-text-output-string">length of the string</a> pointed to by <i>lpchText</i>. If <i>cchText</i> is -1, then the <i>lpchText</i> parameter is assumed to be a pointer to a null-terminated string and <b>DrawTextEx</b> computes the character count automatically.</param>
/// <param name="lprc">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the rectangle, in logical coordinates, in which the text is to be formatted.</param>
/// <param name="format"></param>
/// <param name="lpdtp">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-drawtextparams">DRAWTEXTPARAMS</a> structure that specifies additional formatting options. This parameter can be <b>NULL</b>.</param>
/// <returns>
/// <para>If the function succeeds, the return value is the text height in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from <c>lprc->top</c> to the bottom of the drawn text If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <b>DrawTextEx</b> function supports only fonts whose escapement and orientation are both zero. The text alignment mode for the device context must include the TA_LEFT, TA_TOP, and TA_NOUPDATECP flags.</para>
/// <para>> [!NOTE] > The winuser.h header defines DrawTextEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-drawtextexw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "DrawTextExW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe int DrawTextEx(winmdroot.Graphics.Gdi.HDC hdc, winmdroot.Foundation.PWSTR lpchText, int cchText, winmdroot.Foundation.RECT* lprc, winmdroot.Graphics.Gdi.DRAW_TEXT_FORMAT format, [Optional] winmdroot.Graphics.Gdi.DRAWTEXTPARAMS* lpdtp);
/// <summary>Enables, disables, or grays the specified menu item.</summary>
/// <param name="hMenu">
/// <para>Type: <b>HMENU</b> A handle to the menu.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablemenuitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uIDEnableItem">
/// <para>Type: <b>UINT</b> The menu item to be enabled, disabled, or grayed, as determined by the <i>uEnable</i> parameter. This parameter specifies an item in a menu bar, menu, or submenu.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablemenuitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uEnable">Type: <b>UINT</b></param>
/// <returns>
/// <para>Type: <b>BOOL</b> The return value specifies the previous state of the menu item (it is either <b>MF_DISABLED</b>, <b>MF_ENABLED</b>, or <b>MF_GRAYED</b>). If the menu item does not exist, the return value is -1.</para>
/// </returns>
/// <remarks>
/// <para>An application must use the <b>MF_BYPOSITION</b> flag to specify the correct menu handle. If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected. To set the state of an item in a drop-down menu or submenu by position, an application must specify a handle to the drop-down menu or submenu. When an application specifies the <b>MF_BYCOMMAND</b> flag, the system checks all items that open submenus in the menu identified by the specified menu handle. Therefore, unless duplicate menu items are present, specifying the menu handle to the menu bar is sufficient. The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-insertmenua">InsertMenu</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-insertmenuitema">InsertMenuItem</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-loadmenuindirecta">LoadMenuIndirect</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-modifymenua">ModifyMenu</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setmenuiteminfoa">SetMenuItemInfo</a> functions can also set the state (enabled, disabled, or grayed) of a menu item. When you change a window menu, the menu bar is not immediately updated. To force the update, call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-drawmenubar">DrawMenuBar</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablemenuitem#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL EnableMenuItem(winmdroot.UI.WindowsAndMessaging.HMENU hMenu, uint uIDEnableItem, winmdroot.UI.WindowsAndMessaging.MENU_ITEM_FLAGS uEnable);
/// <summary>The EnableScrollBar function enables or disables one or both scroll bar arrows.</summary>
/// <param name="hWnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to a window or a scroll bar control, depending on the value of the <i>wSBflags</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablescrollbar#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wSBflags">Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b></param>
/// <param name="wArrows">Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b></param>
/// <returns>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> If the arrows are enabled or disabled as specified, the return value is nonzero. If the arrows are already in the requested state or an error occurs, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablescrollbar">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static winmdroot.Foundation.BOOL EnableScrollBar(winmdroot.Foundation.HWND hWnd, uint wSBflags, winmdroot.UI.Controls.ENABLE_SCROLL_BAR_ARROWS wArrows)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, wSBflags, wArrows);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "EnableScrollBar"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, uint wSBflags, winmdroot.UI.Controls.ENABLE_SCROLL_BAR_ARROWS wArrows);
}
/// <summary>Enables or disables mouse and keyboard input to the specified window or control. When input is disabled, the window does not receive input such as mouse clicks and key presses. When input is enabled, the window receives all input.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be enabled or disabled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablewindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bEnable">
/// <para>Type: <b>BOOL</b> Indicates whether to enable or disable the window. If this parameter is <b>TRUE</b>, the window is enabled. If the parameter is <b>FALSE</b>, the window is disabled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablewindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window was previously disabled, the return value is nonzero. If the window was not previously disabled, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>If the window is being disabled, the system sends a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-cancelmode">WM_CANCELMODE</a> message. If the enabled state of a window is changing, the system sends a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-enable">WM_ENABLE</a> message after the <b>WM_CANCELMODE</b> message. (These messages are sent before <b>EnableWindow</b> returns.) If a window is already disabled, its child windows are implicitly disabled, although they are not sent a <b>WM_ENABLE</b> message. A window must be enabled before it can be activated. For example, if an application is displaying a modeless dialog box and has disabled its main window, the application must enable the main window before destroying the dialog box. Otherwise, another window will receive the keyboard focus and be activated. If a child window is disabled, it is ignored when the system tries to determine which window should receive mouse messages. By default, a window is enabled when it is created. To create a window that is initially disabled, an application can specify the <b>WS_DISABLED</b> style in the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowa">CreateWindow</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowexa">CreateWindowEx</a> function. After a window has been created, an application can use <b>EnableWindow</b> to enable or disable the window. An application can use this function to enable or disable a control in a dialog box. A disabled control cannot receive the keyboard focus, nor can a user gain access to it.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enablewindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL EnableWindow(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.BOOL bEnable);
/// <summary>Destroys a modal dialog box, causing the system to end any processing for the dialog box.</summary>
/// <param name="hDlg">
/// <para>Type: <b>HWND</b> A handle to the dialog box to be destroyed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enddialog#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nResult">
/// <para>Type: <b>INT_PTR</b> The value to be returned to the application from the function that created the dialog box.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enddialog#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>Dialog boxes created by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-dialogboxa">DialogBox</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-dialogboxparama">DialogBoxParam</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-dialogboxindirecta">DialogBoxIndirect</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-dialogboxindirectparama">DialogBoxIndirectParam</a> functions must be destroyed using the <b>EndDialog</b> function. An application calls <b>EndDialog</b> from within the dialog box procedure; the function must not be used for any other purpose. A dialog box procedure can call <b>EndDialog</b> at any time, even during the processing of the <a href="https://docs.microsoft.com/windows/desktop/dlgbox/wm-initdialog">WM_INITDIALOG</a> message. If your application calls the function while <b>WM_INITDIALOG</b> is being processed, the dialog box is destroyed before it is shown and before the input focus is set. <b>EndDialog</b> does not destroy the dialog box immediately. Instead, it sets a flag and allows the dialog box procedure to return control to the system. The system checks the flag before attempting to retrieve the next message from the application queue. If the flag is set, the system ends the message loop, destroys the dialog box, and uses the value in <i>nResult</i> as the return value from the function that created the dialog box.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enddialog#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL EndDialog(winmdroot.Foundation.HWND hDlg, nint nResult)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hDlg, nResult);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "EndDialog"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hDlg, nint nResult);
}
/// <inheritdoc cref="EnumDisplaySettings(winmdroot.Foundation.PCWSTR, winmdroot.Graphics.Gdi.ENUM_DISPLAY_SETTINGS_MODE, winmdroot.Graphics.Gdi.DEVMODEW*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL EnumDisplaySettings(string lpszDeviceName, winmdroot.Graphics.Gdi.ENUM_DISPLAY_SETTINGS_MODE iModeNum, ref winmdroot.Graphics.Gdi.DEVMODEW lpDevMode)
{
fixed (winmdroot.Graphics.Gdi.DEVMODEW* lpDevModeLocal = &lpDevMode)
{
fixed (char* lpszDeviceNameLocal = lpszDeviceName)
{
winmdroot.Foundation.BOOL __result = PInvoke.EnumDisplaySettings(lpszDeviceNameLocal, iModeNum, lpDevModeLocal);
return __result;
}
}
}
/// <summary>The EnumDisplaySettings function retrieves information about one of the graphics modes for a display device. To retrieve information for all the graphics modes of a display device, make a series of calls to this function. (Unicode)</summary>
/// <param name="lpszDeviceName">
/// <para>A pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information. This parameter is either <b>NULL</b> or a <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/ns-wingdi-display_devicea">DISPLAY_DEVICE</a>.<b>DeviceName</b> returned from <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-enumdisplaydevicesa">EnumDisplayDevices</a>. A <b>NULL</b> value specifies the current display device on the computer on which the calling thread is running.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="iModeNum"></param>
/// <param name="lpDevMode">
/// <para>A pointer to a <a href="https://docs.microsoft.com/windows/win32/api/wingdi/ns-wingdi-devmodea">DEVMODE</a> structure into which the function stores information about the specified graphics mode. Before calling <b>EnumDisplaySettings</b>, set the <b>dmSize</b> member to <c>sizeof(DEVMODE)</c>, and set the <b>dmDriverExtra</b> member to indicate the size, in bytes, of the additional space available to receive private driver data. The <b>EnumDisplaySettings</b> function sets values for the following five <a href="https://docs.microsoft.com/windows/win32/api/wingdi/ns-wingdi-devmodea">DEVMODE</a> members: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The function fails if <i>iModeNum</i> is greater than the index of the display device's last graphics mode. As noted in the description of the <i>iModeNum</i> parameter, you can use this behavior to enumerate all of a display device's graphics modes. <h3><a id="DPI_Virtualization"></a><a id="dpi_virtualization"></a><a id="DPI_VIRTUALIZATION"></a>DPI Virtualization</h3> This API does not participate in DPI virtualization. The output given is always in terms of physical pixels, and is not related to the calling context.</para>
/// <para>> [!NOTE] > The winuser.h header defines EnumDisplaySettings as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "EnumDisplaySettingsW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL EnumDisplaySettings(winmdroot.Foundation.PCWSTR lpszDeviceName, winmdroot.Graphics.Gdi.ENUM_DISPLAY_SETTINGS_MODE iModeNum, winmdroot.Graphics.Gdi.DEVMODEW* lpDevMode);
/// <inheritdoc cref="FillRect(winmdroot.Graphics.Gdi.HDC, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.HBRUSH)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe int FillRect(winmdroot.Graphics.Gdi.HDC hDC, in winmdroot.Foundation.RECT lprc, winmdroot.Graphics.Gdi.HBRUSH hbr)
{
fixed (winmdroot.Foundation.RECT* lprcLocal = &lprc)
{
int __result = PInvoke.FillRect(hDC, lprcLocal, hbr);
return __result;
}
}
/// <summary>The FillRect function fills a rectangle by using the specified brush. This function includes the left and top borders, but excludes the right and bottom borders of the rectangle.</summary>
/// <param name="hDC">A handle to the device context.</param>
/// <param name="lprc">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the logical coordinates of the rectangle to be filled.</param>
/// <param name="hbr">A handle to the brush used to fill the rectangle.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The brush identified by the <i>hbr</i> parameter may be either a handle to a logical brush or a color value. If specifying a handle to a logical brush, call one of the following functions to obtain the handle: <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-createhatchbrush">CreateHatchBrush</a>, <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-createpatternbrush">CreatePatternBrush</a>, or <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-createsolidbrush">CreateSolidBrush</a>. Additionally, you may retrieve a handle to one of the stock brushes by using the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-getstockobject">GetStockObject</a> function. If specifying a color value for the <i>hbr</i> parameter, it must be one of the standard system colors (the value 1 must be added to the chosen color). For example:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-fillrect#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe int FillRect(winmdroot.Graphics.Gdi.HDC hDC, winmdroot.Foundation.RECT* lprc, winmdroot.Graphics.Gdi.HBRUSH hbr);
/// <inheritdoc cref="FindWindow(winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.HWND FindWindow(string lpClassName, string lpWindowName)
{
fixed (char* lpWindowNameLocal = lpWindowName)
{
fixed (char* lpClassNameLocal = lpClassName)
{
winmdroot.Foundation.HWND __result = PInvoke.FindWindow(lpClassNameLocal, lpWindowNameLocal);
return __result;
}
}
}
/// <summary>Retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search. (Unicode)</summary>
/// <param name="lpClassName">
/// <para>Type: <b>LPCTSTR</b> The class name or a class atom created by a previous call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassexa">RegisterClassEx</a> function. The atom must be in the low-order word of <i>lpClassName</i>; the high-order word must be zero. If <i>lpClassName</i> points to a string, it specifies the window class name. The class name can be any name registered with <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassexa">RegisterClassEx</a>, or any of the predefined control-class names. If <i>lpClassName</i> is <b>NULL</b>, it finds any window whose title matches the <i>lpWindowName</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-findwindoww#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpWindowName">
/// <para>Type: <b>LPCTSTR</b> The window name (the window's title). If this parameter is <b>NULL</b>, all window names match.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-findwindoww#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is a handle to the window that has the specified class name and window name. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>If the <i>lpWindowName</i> parameter is not <b>NULL</b>, <b>FindWindow</b> calls the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowtexta">GetWindowText</a> function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks for <b>GetWindowText</b>.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND FindWindow(winmdroot.Foundation.PCWSTR lpClassName, winmdroot.Foundation.PCWSTR lpWindowName)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(lpClassName, lpWindowName);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "FindWindowW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.PCWSTR lpClassName, winmdroot.Foundation.PCWSTR lpWindowName);
}
/// <summary>Retrieves the window handle to the active window attached to the calling thread's message queue.</summary>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is the handle to the active window attached to the calling thread's message queue. Otherwise, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>To get the handle to the foreground window, you can use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getforegroundwindow">GetForegroundWindow</a>. To get the window handle to the active window in the message queue for another thread, use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getguithreadinfo">GetGUIThreadInfo</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getactivewindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND GetActiveWindow();
/// <summary>Retrieves the handle to the ancestor of the specified window.</summary>
/// <param name="hwnd">
/// <para>Type: <b>HWND</b> A handle to the window whose ancestor is to be retrieved. If this parameter is the desktop window, the function returns <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getancestor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="gaFlags">Type: <b>UINT</b></param>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is the handle to the ancestor window.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getancestor">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND GetAncestor(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.GET_ANCESTOR_FLAGS gaFlags);
/// <summary>Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.</summary>
/// <param name="vKey">
/// <para>Type: <b>int</b> The virtual-key code. For more information, see <a href="https://docs.microsoft.com/windows/desktop/inputdev/virtual-key-codes">Virtual Key Codes</a>. You can use left- and right-distinguishing constants to specify certain keys. See the Remarks section for further information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getasynckeystate#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>SHORT</b> If the function succeeds, the return value specifies whether the key was pressed since the last call to <b>GetAsyncKeyState</b>, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to <b>GetAsyncKeyState</b>. However, you should not rely on this last behavior; for more information, see the Remarks. The return value is zero for the following cases: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The <b>GetAsyncKeyState</b> function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call <b>GetAsyncKeyState</b>(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling <c>GetSystemMetrics(SM_SWAPBUTTON)</c>. which returns TRUE if the mouse buttons have been swapped. Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the preemptive multitasking nature of Windows, another application can call <b>GetAsyncKeyState</b> and receive the "recently pressed" bit instead of your application. The behavior of the least significant bit of the return value is retained strictly for compatibility with 16-bit Windows applications (which are non-preemptive) and should not be relied upon. You can use the virtual-key code constants <b>VK_SHIFT</b>, <b>VK_CONTROL</b>, and <b>VK_MENU</b> as values for the <i>vKey</i> parameter. This gives the state of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. You can use the following virtual-key code constants as values for <i>vKey</i> to distinguish between the left and right instances of those keys. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getasynckeystate#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern short GetAsyncKeyState(int vKey);
/// <summary>Retrieves the DPI_AWARENESS value from a DPI_AWARENESS_CONTEXT.</summary>
/// <param name="value">The <b>DPI_AWARENESS_CONTEXT</b> you want to examine.</param>
/// <returns>The <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a>. If the provided <i>value</i> is <b>null</b> or invalid, this method will return <b>DPI_AWARENESS_INVALID</b>.</returns>
/// <remarks>A <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> contains multiple pieces of information. For example, it includes both the current and the inherited <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a>. This method retrieves the <b>DPI_AWARENESS</b> from the structure.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.UI.HiDpi.DPI_AWARENESS GetAwarenessFromDpiAwarenessContext(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT value);
/// <summary>Retrieves a handle to the window (if any) that has captured the mouse. Only one window at a time can capture the mouse; this window receives mouse input whether or not the cursor is within its borders.</summary>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is a handle to the capture window associated with the current thread. If no window in the thread has captured the mouse, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>A <b>NULL</b> return value means the current thread has not captured the mouse. However, it is possible that another thread or process has captured the mouse. To get a handle to the capture window on another thread, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getguithreadinfo">GetGUIThreadInfo</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcapture#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND GetCapture();
/// <summary>Retrieves the time required to invert the caret's pixels. The user can set this value.</summary>
/// <returns>
/// <para>Type: <b>UINT</b> If the function succeeds, the return value is the blink time, in milliseconds.</para>
/// <para>A return value of <b>INFINITE</b> indicates that the caret does not blink. A return value is zero indicates that the function has failed. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcaretblinktime">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static uint GetCaretBlinkTime()
{
Marshal.SetLastSystemError(0);
uint __retVal = LocalExternFunction();
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetCaretBlinkTime"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern uint LocalExternFunction();
}
/// <inheritdoc cref="GetCaretPos(global::System.Drawing.Point*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetCaretPos(out global::System.Drawing.Point lpPoint)
{
fixed (global::System.Drawing.Point* lpPointLocal = &lpPoint)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetCaretPos(lpPointLocal);
return __result;
}
}
/// <summary>Copies the caret's position to the specified POINT structure.</summary>
/// <param name="lpPoint">
/// <para>Type: <b>LPPOINT</b> A pointer to the <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure that is to receive the client coordinates of the caret.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcaretpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The caret position is always given in the client coordinates of the window that contains the caret. <h3><a id="DPI_Virtualization"></a><a id="dpi_virtualization"></a><a id="DPI_VIRTUALIZATION"></a>DPI Virtualization</h3> This API does not participate in DPI virtualization. The returned values are interpreted as logical sizes in terms of the window in question. The calling thread is not taken into consideration.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcaretpos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetCaretPos(global::System.Drawing.Point* lpPoint)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpPoint);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetCaretPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(global::System.Drawing.Point* lpPoint);
}
/// <inheritdoc cref="GetClassInfo(winmdroot.Foundation.HINSTANCE, winmdroot.Foundation.PCWSTR, winmdroot.UI.WindowsAndMessaging.WNDCLASSW*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetClassInfo(winmdroot.Foundation.HINSTANCE hInstance, string lpClassName, out winmdroot.UI.WindowsAndMessaging.WNDCLASSW lpWndClass)
{
fixed (winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClassLocal = &lpWndClass)
{
fixed (char* lpClassNameLocal = lpClassName)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetClassInfo(hInstance, lpClassNameLocal, lpWndClassLocal);
return __result;
}
}
}
/// <summary>Retrieves information about a window class. (Unicode)</summary>
/// <param name="hInstance">
/// <para>Type: <b>HINSTANCE</b> A handle to the instance of the application that created the class. To retrieve information about classes defined by the system (such as buttons or list boxes), set this parameter to <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassinfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpClassName">
/// <para>Type: <b>LPCTSTR</b> The class name. The name must be that of a preregistered class or a class registered by a previous call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassexa">RegisterClassEx</a> function. Alternatively, this parameter can be an atom. If so, it must be a class atom created by a previous call to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassexa">RegisterClassEx</a>. The atom must be in the low-order word of <i>lpClassName</i>; the high-order word must be zero.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassinfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpWndClass">
/// <para>Type: <b>LPWNDCLASS</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-wndclassa">WNDCLASS</a> structure that receives the information about the class.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassinfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function finds a matching class and successfully copies the data, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>> [!NOTE] > The winuser.h header defines GetClassInfo as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassinfow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetClassInfo(winmdroot.Foundation.HINSTANCE hInstance, winmdroot.Foundation.PCWSTR lpClassName, winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClass)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hInstance, lpClassName, lpWndClass);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetClassInfoW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HINSTANCE hInstance, winmdroot.Foundation.PCWSTR lpClassName, winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClass);
}
/// <summary>Retrieves the name of the class to which the specified window belongs. (GetClassNameW)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window and, indirectly, the class to which the window belongs.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassnamew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpClassName">
/// <para>Type: <b>LPTSTR</b> The class name string.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassnamew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nMaxCount">
/// <para>Type: <b>int</b> The length of the *lpClassName* buffer, in characters. The buffer must be large enough to include the terminating null character; otherwise, the class name string is truncated to `nMaxCount-1` characters.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassnamew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> If the function succeeds, the return value is the number of characters copied to the buffer, not including the terminating null character. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>> [!NOTE] > The winuser.h header defines GetClassName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclassnamew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static int GetClassName(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PWSTR lpClassName, int nMaxCount)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(hWnd, lpClassName, nMaxCount);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetClassNameW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern int LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PWSTR lpClassName, int nMaxCount);
}
/// <inheritdoc cref="GetClipCursor(winmdroot.Foundation.RECT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetClipCursor(out winmdroot.Foundation.RECT lpRect)
{
fixed (winmdroot.Foundation.RECT* lpRectLocal = &lpRect)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetClipCursor(lpRectLocal);
return __result;
}
}
/// <summary>Retrieves the screen coordinates of the rectangular area to which the cursor is confined.</summary>
/// <param name="lpRect">
/// <para>Type: <b>LPRECT</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that receives the screen coordinates of the confining rectangle. The structure receives the dimensions of the screen if the cursor is not confined to a rectangle.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclipcursor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The cursor is a shared resource. If an application confines the cursor with the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-clipcursor">ClipCursor</a> function, it must later release the cursor by using <b>ClipCursor</b> before relinquishing control to another application. The calling process must have <b>WINSTA_READATTRIBUTES</b> access to the window station.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getclipcursor#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetClipCursor(winmdroot.Foundation.RECT* lpRect)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpRect);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetClipCursor"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.RECT* lpRect);
}
/// <inheritdoc cref="GetComboBoxInfo(winmdroot.Foundation.HWND, winmdroot.UI.Controls.COMBOBOXINFO*)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetComboBoxInfo(winmdroot.Foundation.HWND hwndCombo, ref winmdroot.UI.Controls.COMBOBOXINFO pcbi)
{
fixed (winmdroot.UI.Controls.COMBOBOXINFO* pcbiLocal = &pcbi)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetComboBoxInfo(hwndCombo, pcbiLocal);
return __result;
}
}
/// <summary>Retrieves information about the specified combo box.</summary>
/// <param name="hwndCombo">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> A handle to the combo box.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcomboboxinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pcbi">
/// <para>Type: <b>PCOMBOBOXINFO</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-comboboxinfo">COMBOBOXINFO</a> structure that receives the information. You must set <b>COMBOBOXINFO.cbSize</b> before calling this function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcomboboxinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>The <a href="https://docs.microsoft.com/windows/desktop/Controls/cb-getcomboboxinfo">CB_GETCOMBOBOXINFO</a> message is equivalent to this function.</remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetComboBoxInfo(winmdroot.Foundation.HWND hwndCombo, winmdroot.UI.Controls.COMBOBOXINFO* pcbi)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hwndCombo, pcbi);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetComboBoxInfo"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hwndCombo, winmdroot.UI.Controls.COMBOBOXINFO* pcbi);
}
/// <summary>Retrieves a handle to the current cursor.</summary>
/// <returns>
/// <para>Type: <b>HCURSOR</b> The return value is the handle to the current cursor. If there is no cursor, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcursor">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.UI.WindowsAndMessaging.HCURSOR GetCursor();
/// <inheritdoc cref="GetCursorPos(global::System.Drawing.Point*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetCursorPos(out global::System.Drawing.Point lpPoint)
{
fixed (global::System.Drawing.Point* lpPointLocal = &lpPoint)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetCursorPos(lpPointLocal);
return __result;
}
}
/// <summary>Retrieves the position of the mouse cursor, in screen coordinates.</summary>
/// <param name="lpPoint">
/// <para>Type: <b>LPPOINT</b> A pointer to a <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure that receives the screen coordinates of the cursor.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcursorpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> Returns nonzero if successful or zero otherwise. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor. The calling process must have <b>WINSTA_READATTRIBUTES</b> access to the window station. The input desktop must be the current desktop when you call <b>GetCursorPos</b>. Call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-openinputdesktop">OpenInputDesktop</a> to determine whether the current desktop is the input desktop. If it is not, call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddesktop">SetThreadDesktop</a> with the <b>HDESK</b> returned by <b>OpenInputDesktop</b> to switch to that desktop.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getcursorpos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetCursorPos(global::System.Drawing.Point* lpPoint)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpPoint);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetCursorPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(global::System.Drawing.Point* lpPoint);
}
/// <summary>Retrieves a handle to a control in the specified dialog box.</summary>
/// <param name="hDlg">
/// <para>Type: <b>HWND</b> A handle to the dialog box that contains the control.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIDDlgItem">
/// <para>Type: <b>int</b> The identifier of the control to be retrieved.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is the window handle of the specified control. If the function fails, the return value is <b>NULL</b>, indicating an invalid dialog box handle or a nonexistent control. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>You can use the <b>GetDlgItem</b> function with any parent-child window pair, not just with dialog boxes. As long as the <i>hDlg</i> parameter specifies a parent window and the child window has a unique identifier (as specified by the <i>hMenu</i> parameter in the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowa">CreateWindow</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowexa">CreateWindowEx</a> function that created the child window), <b>GetDlgItem</b> returns a valid handle to the child window.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND GetDlgItem(winmdroot.Foundation.HWND hDlg, int nIDDlgItem)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hDlg, nIDDlgItem);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetDlgItem"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hDlg, int nIDDlgItem);
}
/// <summary>Translates the text of a specified control in a dialog box into an integer value.</summary>
/// <param name="hDlg">
/// <para>Type: <b>HWND</b> A handle to the dialog box that contains the control of interest.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitemint#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIDDlgItem">
/// <para>Type: <b>int</b> The identifier of the control whose text is to be translated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitemint#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpTranslated">
/// <para>Type: <b>BOOL*</b> Indicates success or failure (<b>TRUE</b> indicates success, <b>FALSE</b> indicates failure). If this parameter is <b>NULL</b>, the function returns no information about success or failure.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitemint#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bSigned">
/// <para>Type: <b>BOOL</b> Indicates whether the function should examine the text for a minus sign at the beginning and return a signed integer value if it finds one (<b>TRUE</b> specifies this should be done, <b>FALSE</b> that it should not).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitemint#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>UINT</b> If the function succeeds, the variable pointed to by <i>lpTranslated</i> is set to <b>TRUE</b>, and the return value is the translated value of the control text. If the function fails, the variable pointed to by <i>lpTranslated</i> is set to <b>FALSE</b>, and the return value is zero. Note that, because zero is a possible translated value, a return value of zero does not by itself indicate failure. If <i>lpTranslated</i> is <b>NULL</b>, the function returns no information about success or failure. Note that, if the <i>bSigned</i> parameter is <b>TRUE</b> and there is a minus sign (–) at the beginning of the text, <b>GetDlgItemInt</b> translates the text into a signed integer value. Otherwise, the function creates an unsigned integer value. To obtain the proper value in this case, cast the return value to an <b>int</b> type. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>GetDlgItemInt</b> function retrieves the text of the specified control by sending the control a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-gettext">WM_GETTEXT</a> message. The function translates the retrieved text by stripping any extra spaces at the beginning of the text and then converting the decimal digits. The function stops translating when it reaches the end of the text or encounters a nonnumeric character. The <b>GetDlgItemInt</b> function returns zero if the translated value is greater than <b>INT_MAX</b> (for signed numbers) or <b>UINT_MAX</b> (for unsigned numbers).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdlgitemint#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe uint GetDlgItemInt(winmdroot.Foundation.HWND hDlg, int nIDDlgItem, [Optional] winmdroot.Foundation.BOOL* lpTranslated, winmdroot.Foundation.BOOL bSigned)
{
Marshal.SetLastSystemError(0);
uint __retVal = LocalExternFunction(hDlg, nIDDlgItem, lpTranslated, bSigned);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetDlgItemInt"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe uint LocalExternFunction(winmdroot.Foundation.HWND hDlg, int nIDDlgItem, [Optional] winmdroot.Foundation.BOOL* lpTranslated, winmdroot.Foundation.BOOL bSigned);
}
/// <summary>Retrieves the current double-click time for the mouse.</summary>
/// <returns>
/// <para>Type: <b>UINT</b> The return value specifies the current double-click time, in milliseconds. The maximum return value is 5000 milliseconds.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdoubleclicktime">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern uint GetDoubleClickTime();
/// <summary>Returns the system DPI.</summary>
/// <returns>The system DPI value.</returns>
/// <remarks>
/// <para>The return value will be dependent based upon the calling context. If the current thread has a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a> value of <b>DPI_AWARENESS_UNAWARE</b>, the return value will be 96. That is because the current context always assumes a DPI of 96. For any other <b>DPI_AWARENESS</b> value, the return value will be the actual system DPI. You should not cache the system DPI, but should use <b>GetDpiForSystem</b> whenever you need the system DPI value.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdpiforsystem#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern uint GetDpiForSystem();
/// <summary>Returns the dots per inch (dpi) value for the specified window.</summary>
/// <param name="hwnd">The window that you want to get information about.</param>
/// <returns>The DPI for the window, which depends on the [DPI_AWARENESS](/windows/win32/api/windef/ne-windef-dpi_awareness) of the window. See the **Remarks** section for more information. An invalid *hwnd* value will result in a return value of 0.</returns>
/// <remarks>
/// <para>The following table indicates the return value of <b>GetDpiForWindow</b> based on the [DPI_AWARENESS](/windows/win32/api/windef/ne-windef-dpi_awareness) of the provided *hwnd*. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getdpiforwindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern uint GetDpiForWindow(winmdroot.Foundation.HWND hwnd);
/// <summary>Retrieves the handle to the window that has the keyboard focus, if the window is attached to the calling thread's message queue.</summary>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is the handle to the window with the keyboard focus. If the calling thread's message queue does not have an associated window with the keyboard focus, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para><b>GetFocus</b> returns the window with the keyboard focus for the current thread's message queue. If <b>GetFocus</b> returns <b>NULL</b>, another thread's queue may be attached to a window that has the keyboard focus. Use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getforegroundwindow">GetForegroundWindow</a> function to retrieve the handle to the window with which the user is currently working. You can associate your thread's message queue with the windows owned by another thread by using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-attachthreadinput">AttachThreadInput</a> function. To get the window with the keyboard focus on the foreground queue or the queue of another thread, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getguithreadinfo">GetGUIThreadInfo</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getfocus#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND GetFocus();
/// <summary>Retrieves the active input locale identifier (formerly called the keyboard layout).</summary>
/// <param name="idThread">
/// <para>Type: <b>DWORD</b> The identifier of the thread to query, or 0 for the current thread.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardlayout#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HKL</b> The return value is the input locale identifier for the thread. The low word contains a <a href="https://docs.microsoft.com/windows/desktop/Intl/language-identifiers">Language Identifier</a> for the input language and the high word contains a device handle to the physical layout of the keyboard.</para>
/// </returns>
/// <remarks>
/// <para>The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input. Since the keyboard layout can be dynamically changed, applications that cache information about the current keyboard layout should process the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-inputlangchange">WM_INPUTLANGCHANGE</a> message to be informed of changes in the input language. To get the KLID (keyboard layout ID) of the currently active HKL, call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeyboardlayoutnamea">GetKeyboardLayoutName</a>. <b>Beginning in Windows 8:</b> The preferred method to retrieve the language associated with the current keyboard layout or input method is a call to <a href="https://docs.microsoft.com/uwp/api/windows.globalization.language.currentinputmethodlanguagetag">Windows.Globalization.Language.CurrentInputMethodLanguageTag</a>. If your app passes language tags from <b>CurrentInputMethodLanguageTag</b> to any <a href="https://docs.microsoft.com/windows/desktop/Intl/national-language-support-functions">National Language Support</a> functions, it must first convert the tags by calling <a href="https://docs.microsoft.com/windows/desktop/api/winnls/nf-winnls-resolvelocalename">ResolveLocaleName</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardlayout#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.UI.Input.KeyboardAndMouse.HKL GetKeyboardLayout(uint idThread);
/// <summary>Retrieves the input locale identifiers (formerly called keyboard layout handles) corresponding to the current set of input locales in the system. The function copies the identifiers to the specified buffer.</summary>
/// <param name="nBuff">
/// <para>Type: <b>int</b> The maximum number of handles that the buffer can hold.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardlayoutlist#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpList">
/// <para>Type: <b>HKL*</b> A pointer to the buffer that receives the array of input locale identifiers.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardlayoutlist#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> If the function succeeds, the return value is the number of input locale identifiers copied to the buffer or, if <i>nBuff</i> is zero, the return value is the size, in array elements, of the buffer needed to receive all current input locale identifiers. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input. <b>Beginning in Windows 8:</b> The preferred method to retrieve the language associated with the current keyboard layout or input method is a call to <a href="https://docs.microsoft.com/uwp/api/windows.globalization.language.currentinputmethodlanguagetag">Windows.Globalization.Language.CurrentInputMethodLanguageTag</a>. If your app passes language tags from <b>CurrentInputMethodLanguageTag</b> to any <a href="https://docs.microsoft.com/windows/desktop/Intl/national-language-support-functions">National Language Support</a> functions, it must first convert the tags by calling <a href="https://docs.microsoft.com/windows/desktop/api/winnls/nf-winnls-resolvelocalename">ResolveLocaleName</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardlayoutlist#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe int GetKeyboardLayoutList(int nBuff, [Optional] winmdroot.UI.Input.KeyboardAndMouse.HKL* lpList)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(nBuff, lpList);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetKeyboardLayoutList"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe int LocalExternFunction(int nBuff, [Optional] winmdroot.UI.Input.KeyboardAndMouse.HKL* lpList);
}
/// <inheritdoc cref="GetKeyboardState(byte*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetKeyboardState(Span<byte> lpKeyState)
{
fixed (byte* lpKeyStateLocal = lpKeyState)
{
if (lpKeyState.Length < 256) throw new ArgumentException();
winmdroot.Foundation.BOOL __result = PInvoke.GetKeyboardState(lpKeyStateLocal);
return __result;
}
}
/// <summary>Copies the status of the 256 virtual keys to the specified buffer.</summary>
/// <param name="lpKeyState">
/// <para>Type: <b>PBYTE</b> The 256-byte array that receives the status data for each virtual key.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardstate#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>An application can call this function to retrieve the current status of all the virtual keys. The status changes as a thread removes keyboard messages from its message queue. The status does not change as keyboard messages are posted to the thread's message queue, nor does it change as keyboard messages are posted to or retrieved from message queues of other threads. (Exception: Threads that are connected through <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-attachthreadinput">AttachThreadInput</a> share the same keyboard state.) When the function returns, each member of the array pointed to by the <i>lpKeyState</i> parameter contains status data for a virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the key is a toggle key, for example CAPS LOCK, then the low-order bit is 1 when the key is toggled and is 0 if the key is untoggled. The low-order bit is meaningless for non-toggle keys. A toggle key is said to be toggled when it is turned on. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled. To retrieve status information for an individual key, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeystate">GetKeyState</a> function. To retrieve the current state for an individual key regardless of whether the corresponding keyboard message has been retrieved from the message queue, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getasynckeystate">GetAsyncKeyState</a> function. An application can use the virtual-key code constants <b>VK_SHIFT</b>, <b>VK_CONTROL</b> and <b>VK_MENU</b> as indices into the array pointed to by <i>lpKeyState</i>. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as indices to distinguish between the left and right instances of those keys: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeyboardstate#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetKeyboardState(byte* lpKeyState)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpKeyState);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetKeyboardState"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(byte* lpKeyState);
}
/// <summary>Retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off�alternating each time the key is pressed).</summary>
/// <param name="nVirtKey">
/// <para>Type: <b>int</b> A virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), <i>nVirtKey</i> must be set to the ASCII value of that character. For other keys, it must be a virtual-key code. If a non-English keyboard layout is used, virtual keys with values in the range ASCII A through Z and 0 through 9 are used to specify most of the character keys. For example, for the German keyboard layout, the virtual key of value ASCII O (0x4F) refers to the "o" key, whereas VK_OEM_1 refers to the "o with umlaut" key.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeystate#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>SHORT</b> The return value specifies the status of the specified virtual key, as follows: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getasynckeystate">GetAsyncKeyState</a> function to retrieve that information. An application calls <b>GetKeyState</b> in response to a keyboard-input message. This function retrieves the state of the key when the input message was generated. To retrieve state information for all the virtual keys, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeyboardstate">GetKeyboardState</a> function. An application can use the <a href="https://docs.microsoft.com/windows/desktop/inputdev/virtual-key-codes">virtual key code</a> constants <b>VK_SHIFT</b>, <b>VK_CONTROL</b>, and <b>VK_MENU</b> as values for the <i>nVirtKey</i> parameter. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as values for <i>nVirtKey</i> to distinguish between the left and right instances of those keys: <b>VK_LSHIFT</b> <b>VK_RSHIFT</b> <b>VK_LCONTROL</b> <b>VK_RCONTROL</b> <b>VK_LMENU</b> <b>VK_RMENU</b> These left- and right-distinguishing constants are available to an application only through the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getkeyboardstate">GetKeyboardState</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setkeyboardstate">SetKeyboardState</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getasynckeystate">GetAsyncKeyState</a>, <b>GetKeyState</b>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-mapvirtualkeya">MapVirtualKey</a> functions.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getkeystate#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern short GetKeyState(int nVirtKey);
/// <summary>Retrieves a handle to the menu assigned to the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose menu handle is to be retrieved.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HMENU</b> The return value is a handle to the menu. If the specified window has no menu, the return value is <b>NULL</b>. If the window is a child window, the return value is undefined.</para>
/// </returns>
/// <remarks><b>GetMenu</b> does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the <a href="https://docs.microsoft.com/previous-versions/ms971350(v=msdn.10)">Active Accessibility</a> APIs.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.UI.WindowsAndMessaging.HMENU GetMenu(winmdroot.Foundation.HWND hWnd);
/// <summary>Determines the number of items in the specified menu.</summary>
/// <param name="hMenu">
/// <para>Type: <b>HMENU</b> A handle to the menu to be examined.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuitemcount#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> If the function succeeds, the return value specifies the number of items in the menu. If the function fails, the return value is -1. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuitemcount">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static int GetMenuItemCount(winmdroot.UI.WindowsAndMessaging.HMENU hMenu)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(hMenu);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetMenuItemCount"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern int LocalExternFunction(winmdroot.UI.WindowsAndMessaging.HMENU hMenu);
}
/// <inheritdoc cref="GetMenuItemInfo(winmdroot.UI.WindowsAndMessaging.HMENU, uint, winmdroot.Foundation.BOOL, winmdroot.UI.WindowsAndMessaging.MENUITEMINFOW*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetMenuItemInfo(winmdroot.UI.WindowsAndMessaging.HMENU hmenu, uint item, winmdroot.Foundation.BOOL fByPosition, ref winmdroot.UI.WindowsAndMessaging.MENUITEMINFOW lpmii)
{
fixed (winmdroot.UI.WindowsAndMessaging.MENUITEMINFOW* lpmiiLocal = &lpmii)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetMenuItemInfo(hmenu, item, fByPosition, lpmiiLocal);
return __result;
}
}
/// <summary>Retrieves information about a menu item. (Unicode)</summary>
/// <param name="hmenu">
/// <para>Type: <b>HMENU</b> A handle to the menu that contains the menu item.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuiteminfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="item">
/// <para>Type: <b>UINT</b> The identifier or position of the menu item to get information about. The meaning of this parameter depends on the value of <i>fByPosition</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuiteminfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="fByPosition">
/// <para>Type: <b>BOOL</b> The meaning of <i>uItem</i>. If this parameter is <b>FALSE</b>, <i>uItem</i> is a menu item identifier. Otherwise, it is a menu item position. See <a href="https://docs.microsoft.com/windows/desktop/menurc/about-menus">Accessing Menu Items Programmatically</a> for more information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuiteminfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpmii">
/// <para>Type: <b>LPMENUITEMINFO</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-menuiteminfoa">MENUITEMINFO</a> structure that specifies the information to retrieve and receives information about the menu item. Note that you must set the <b>cbSize</b> member to <c>sizeof(MENUITEMINFO)</c> before calling this function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuiteminfow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, use the <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> function.</para>
/// </returns>
/// <remarks>
/// <para>To retrieve a menu item of type <b>MFT_STRING</b>, first find the size of the string by setting the <b>dwTypeData</b> member of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-menuiteminfoa">MENUITEMINFO</a> to <b>NULL</b> and then calling <b>GetMenuItemInfo</b>. The value of <b>cch</b>+1 is the size needed. Then allocate a buffer of this size, place the pointer to the buffer in <b>dwTypeData</b>, increment <b>cch</b> by one, and then call <b>GetMenuItemInfo</b> once again to fill the buffer with the string. If the retrieved menu item is of some other type, then <b>GetMenuItemInfo</b> sets the <b>dwTypeData</b> member to a value whose type is specified by the <b>fType</b><b>fType</b> member and sets <b>cch</b> to 0.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmenuiteminfow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetMenuItemInfo(winmdroot.UI.WindowsAndMessaging.HMENU hmenu, uint item, winmdroot.Foundation.BOOL fByPosition, winmdroot.UI.WindowsAndMessaging.MENUITEMINFOW* lpmii)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hmenu, item, fByPosition, lpmii);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetMenuItemInfoW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.HMENU hmenu, uint item, winmdroot.Foundation.BOOL fByPosition, winmdroot.UI.WindowsAndMessaging.MENUITEMINFOW* lpmii);
}
/// <inheritdoc cref="GetMessage(winmdroot.UI.WindowsAndMessaging.MSG*, winmdroot.Foundation.HWND, uint, uint)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetMessage(out winmdroot.UI.WindowsAndMessaging.MSG lpMsg, winmdroot.Foundation.HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax)
{
fixed (winmdroot.UI.WindowsAndMessaging.MSG* lpMsgLocal = &lpMsg)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetMessage(lpMsgLocal, hWnd, wMsgFilterMin, wMsgFilterMax);
return __result;
}
}
/// <summary>Retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval. (GetMessageW)</summary>
/// <param name="lpMsg">
/// <para>Type: <b>LPMSG</b> A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure that receives message information from the thread's message queue.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose messages are to be retrieved. The window must belong to the current thread.</para>
/// <para>If <i>hWnd</i> is <b>NULL</b>, <b>GetMessage</b> retrieves messages for any window that belongs to the current thread, and any messages on the current thread's message queue whose <b>hwnd</b> value is <b>NULL</b> (see the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure). Therefore if hWnd is <b>NULL</b>, both window messages and thread messages are processed. If <i>hWnd</i> is -1, <b>GetMessage</b> retrieves only messages on the current thread's message queue whose <b>hwnd</b> value is <b>NULL</b>, that is, thread messages as posted by <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-postmessagea">PostMessage</a> (when the <i>hWnd</i> parameter is <b>NULL</b>) or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-postthreadmessagea">PostThreadMessage</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wMsgFilterMin">
/// <para>Type: <b>UINT</b> The integer value of the lowest message value to be retrieved. Use <b>WM_KEYFIRST</b> (0x0100) to specify the first keyboard message or <b>WM_MOUSEFIRST</b> (0x0200) to specify the first mouse message. Use <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-input">WM_INPUT</a> here and in <i>wMsgFilterMax</i> to specify only the <b>WM_INPUT</b> messages. If <i>wMsgFilterMin</i> and <i>wMsgFilterMax</i> are both zero, <b>GetMessage</b> returns all available messages (that is, no range filtering is performed).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wMsgFilterMax">
/// <para>Type: <b>UINT</b> The integer value of the highest message value to be retrieved. Use <b>WM_KEYLAST</b> to specify the last keyboard message or <b>WM_MOUSELAST</b> to specify the last mouse message.</para>
/// <para>Use <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-input">WM_INPUT</a> here and in <i>wMsgFilterMin</i> to specify only the <b>WM_INPUT</b> messages. If <i>wMsgFilterMin</i> and <i>wMsgFilterMax</i> are both zero, <b>GetMessage</b> returns all available messages (that is, no range filtering is performed).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function retrieves a message other than <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a>, the return value is nonzero. If the function retrieves the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a> message, the return value is zero. If there is an error, the return value is -1. For example, the function fails if <i>hWnd</i> is an invalid window handle or <i>lpMsg</i> is an invalid pointer. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. Because the return value can be nonzero, zero, or -1, avoid code like this:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>An application typically uses the return value to determine whether to end the main message loop and exit the program. The <b>GetMessage</b> function retrieves messages associated with the window identified by the <i>hWnd</i> parameter or any of its children, as specified by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-ischild">IsChild</a> function, and within the range of message values given by the <i>wMsgFilterMin</i> and <i>wMsgFilterMax</i> parameters. Note that an application can only use the low word in the <i>wMsgFilterMin</i> and <i>wMsgFilterMax</i> parameters; the high word is reserved for the system. Note that <b>GetMessage</b> always retrieves <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a> messages, no matter which values you specify for <i>wMsgFilterMin</i> and <i>wMsgFilterMax</i>. During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows owned by the calling thread using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendmessage">SendMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendmessagecallbacka">SendMessageCallback</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendmessagetimeouta">SendMessageTimeout</a>, or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendnotifymessagea">SendNotifyMessage</a> function. Then the first queued message that matches the specified filter is retrieved. The system may also process internal events. If no filter is specified, messages are processed in the following order:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetMessage(winmdroot.UI.WindowsAndMessaging.MSG* lpMsg, winmdroot.Foundation.HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.MSG* lpMsg, winmdroot.Foundation.HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
}
/// <summary>Retrieves the cursor position for the last message retrieved by the GetMessage function.</summary>
/// <returns>
/// <para>Type: <b>DWORD</b> The return value specifies the x- and y-coordinates of the cursor position. The x-coordinate is the low order <b>short</b> and the y-coordinate is the high-order <b>short</b>.</para>
/// </returns>
/// <remarks>
/// <para>As noted above, the x-coordinate is in the low-order <b>short</b> of the return value; the y-coordinate is in the high-order <b>short</b> (both represent <i>signed</i> values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-makepoints">MAKEPOINTS</a> macro to obtain a <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-points">POINTS</a> structure from the return value. You can also use the <a href="https://docs.microsoft.com/windows/desktop/api/windowsx/nf-windowsx-get_x_lparam">GET_X_LPARAM</a> or <a href="https://docs.microsoft.com/windows/desktop/api/windowsx/nf-windowsx-get_y_lparam">GET_Y_LPARAM</a> macro to extract the x- or y-coordinate. <div class="alert"><b>Important</b> Do not use the <a href="https://docs.microsoft.com/previous-versions/windows/desktop/legacy/ms632659(v=vs.85)">LOWORD</a> or <a href="https://docs.microsoft.com/previous-versions/windows/desktop/legacy/ms632657(v=vs.85)">HIWORD</a> macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and <b>LOWORD</b> and <b>HIWORD</b> treat the coordinates as unsigned quantities.</div> <div> </div></para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagepos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern uint GetMessagePos();
/// <summary>Retrieves the message time for the last message retrieved by the GetMessage function.</summary>
/// <returns>
/// <para>Type: <b>LONG</b> The return value specifies the message time.</para>
/// </returns>
/// <remarks>
/// <para>The return value from the <b>GetMessageTime</b> function does not necessarily increase between subsequent messages, because the value wraps to the minimum value for a long integer if the timer count exceeds the maximum value for a long integer. To calculate time delays between messages, subtract the time of the first message from the time of the second message (ignoring overflow) and compare the result of the subtraction against the desired delay amount.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmessagetime#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern int GetMessageTime();
/// <summary>Retrieves a handle to the specified window's parent or owner.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose parent window handle is to be retrieved.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getparent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window with the <b>WS_POPUP</b> style, the return value is a handle to the owner window. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. This function typically fails for one of the following reasons:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>To obtain a window's owner window, instead of using <b>GetParent</b>, use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindow">GetWindow</a> with the <b>GW_OWNER</b> flag. To obtain the parent window and not the owner, instead of using <b>GetParent</b>, use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getancestor">GetAncestor</a> with the <b>GA_PARENT</b> flag.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND GetParent(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetParent"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <inheritdoc cref="GetPhysicalCursorPos(global::System.Drawing.Point*)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetPhysicalCursorPos(out global::System.Drawing.Point lpPoint)
{
fixed (global::System.Drawing.Point* lpPointLocal = &lpPoint)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetPhysicalCursorPos(lpPointLocal);
return __result;
}
}
/// <summary>Retrieves the position of the cursor in physical coordinates.</summary>
/// <param name="lpPoint">
/// <para>Type: <b>LPPOINT</b> The position of the cursor, in physical coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getphysicalcursorpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> <b>TRUE</b> if successful; otherwise <b>FALSE</b>.</para>
/// <para><a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> can be called to get more information about any error that is generated.</para>
/// </returns>
/// <remarks>For a description of the difference between logical coordinates and physical coordinates, see <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-physicaltologicalpoint">PhysicalToLogicalPoint</a>.</remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetPhysicalCursorPos(global::System.Drawing.Point* lpPoint)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpPoint);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetPhysicalCursorPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(global::System.Drawing.Point* lpPoint);
}
/// <summary>Closes an open window station handle.</summary>
/// <param name="hWinSta">
/// <para>A handle to the window station to be closed. This handle is returned by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowstationa">CreateWindowStation</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-openwindowstationa">OpenWindowStation</a> function. Do not specify the handle returned by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getprocesswindowstation">GetProcessWindowStation</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-closewindowstation#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. <b>Windows Server 2003 and Windows XP/2000: </b>This function does not set the last error code on failure.</para>
/// </returns>
/// <remarks>
/// <para>The <b>CloseWindowStation</b> function will fail if the handle being closed is for the window station assigned to the calling process.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-closewindowstation#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL CloseWindowStation(winmdroot.System.StationsAndDesktops.HWINSTA hWinSta)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWinSta);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "CloseWindowStation"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.System.StationsAndDesktops.HWINSTA hWinSta);
}
/// <summary>Retrieves a handle to the current window station for the calling process.</summary>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the window station. If the function fails, the return value is NULL. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The system associates a window station with a process when the process is created. A process can use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setprocesswindowstation">SetProcessWindowStation</a> function to change its window station. The calling process can use the returned handle in calls to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getuserobjectinformationa">GetUserObjectInformation</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getuserobjectsecurity">GetUserObjectSecurity</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setuserobjectinformationa">SetUserObjectInformation</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setuserobjectsecurity">SetUserObjectSecurity</a> functions. Do not close the handle returned by this function. A service application is created with an associated window station and desktop, so there is no need to call a USER or GDI function to connect the service to a window station and desktop.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getprocesswindowstation#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.System.StationsAndDesktops.HWINSTA GetProcessWindowStation()
{
Marshal.SetLastSystemError(0);
winmdroot.System.StationsAndDesktops.HWINSTA __retVal = LocalExternFunction();
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetProcessWindowStation"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.System.StationsAndDesktops.HWINSTA LocalExternFunction();
}
/// <inheritdoc cref="GetScrollInfo(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS, winmdroot.UI.WindowsAndMessaging.SCROLLINFO*)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetScrollInfo(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, ref winmdroot.UI.WindowsAndMessaging.SCROLLINFO lpsi)
{
fixed (winmdroot.UI.WindowsAndMessaging.SCROLLINFO* lpsiLocal = &lpsi)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetScrollInfo(hwnd, nBar, lpsiLocal);
return __result;
}
}
/// <summary>The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).</summary>
/// <param name="hwnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the <i>fnBar</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getscrollinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nBar">Type: <b>int</b></param>
/// <param name="lpsi">
/// <para>Type: <b>LPSCROLLINFO</b> Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-scrollinfo">SCROLLINFO</a> structure. Before calling <b>GetScrollInfo</b>, set the <b>cbSize</b> member to <b>sizeof</b>(<b>SCROLLINFO</b>), and set the <b>fMask</b> member to specify the scroll bar parameters to retrieve. Before returning, the function copies the specified parameters to the appropriate members of the structure. The</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getscrollinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> If the function retrieved any values, the return value is nonzero. If the function does not retrieve any values, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>GetScrollInfo</b> function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll bar position, <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-hscroll">WM_HSCROLL</a> and <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-vscroll">WM_VSCROLL</a>, provide only 16 bits of position data, the functions <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setscrollinfo">SetScrollInfo</a> and <b>GetScrollInfo</b> provide 32 bits of scroll bar position data. Thus, an application can call <b>GetScrollInfo</b> while processing either the <b>WM_HSCROLL</b> or <b>WM_VSCROLL</b> messages to obtain 32-bit scroll bar position data. To get the 32-bit position of the scroll box (thumb) during a SB_THUMBTRACK request code in a <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-hscroll">WM_HSCROLL</a> or <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-vscroll">WM_VSCROLL</a> message, call <b>GetScrollInfo</b> with the SIF_TRACKPOS value in the <b>fMask</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-scrollinfo">SCROLLINFO</a> structure. The function returns the tracking position of the scroll box in the <b>nTrackPos</b> member of the <b>SCROLLINFO</b> structure. This allows you to get the position of the scroll box as the user moves it. The following sample code illustrates the technique.</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getscrollinfo#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL GetScrollInfo(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, winmdroot.UI.WindowsAndMessaging.SCROLLINFO* lpsi)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hwnd, nBar, lpsi);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetScrollInfo"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, winmdroot.UI.WindowsAndMessaging.SCROLLINFO* lpsi);
}
/// <summary>Enables the application to access the window menu (also known as the system menu or the control menu) for copying and modifying.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window that will own a copy of the window menu.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getsystemmenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bRevert">
/// <para>Type: <b>BOOL</b> The action to be taken. If this parameter is <b>FALSE</b>, <b>GetSystemMenu</b> returns a handle to the copy of the window menu currently in use. The copy is initially identical to the window menu, but it can be modified. If this parameter is <b>TRUE</b>, <b>GetSystemMenu</b> resets the window menu back to the default state. The previous window menu, if any, is destroyed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getsystemmenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HMENU</b> If the <i>bRevert</i> parameter is <b>FALSE</b>, the return value is a handle to a copy of the window menu. If the <i>bRevert</i> parameter is <b>TRUE</b>, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>Any window that does not use the <b>GetSystemMenu</b> function to make its own copy of the window menu receives the standard window menu. The window menu initially contains items with various identifier values, such as <b>SC_CLOSE</b>, <b>SC_MOVE</b>, and <b>SC_SIZE</b>. Menu items on the window menu send <a href="https://docs.microsoft.com/windows/desktop/menurc/wm-syscommand">WM_SYSCOMMAND</a> messages. All predefined window menu items have identifier numbers greater than 0xF000. If an application adds commands to the window menu, it should use identifier numbers less than 0xF000. The system automatically grays items on the standard window menu, depending on the situation. The application can perform its own checking or graying by responding to the <a href="https://docs.microsoft.com/windows/desktop/menurc/wm-initmenu">WM_INITMENU</a> message that is sent before any menu is displayed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getsystemmenu#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.UI.WindowsAndMessaging.HMENU GetSystemMenu(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.BOOL bRevert);
/// <summary>Retrieves the specified system metric or system configuration setting taking into account a provided DPI.</summary>
/// <param name="nIndex">The system metric or configuration setting to be retrieved. See <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getsystemmetrics">GetSystemMetrics</a> for the possible values.</param>
/// <param name="dpi">The DPI to use for scaling the metric.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>This function returns the same result as <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getsystemmetrics">GetSystemMetrics</a> but scales it according to an arbitrary DPI you provide if appropriate.</remarks>
[SupportedOSPlatform("windows10.0.14393")]
internal static int GetSystemMetricsForDpi(winmdroot.UI.WindowsAndMessaging.SYSTEM_METRICS_INDEX nIndex, uint dpi)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(nIndex, dpi);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetSystemMetricsForDpi"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern int LocalExternFunction(winmdroot.UI.WindowsAndMessaging.SYSTEM_METRICS_INDEX nIndex, uint dpi);
}
/// <summary>Gets the DPI_AWARENESS_CONTEXT for the current thread.</summary>
/// <returns>The current <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for the thread.</returns>
/// <remarks>This method will return the latest <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> sent to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddpiawarenesscontext">SetThreadDpiAwarenessContext</a>. If <b>SetThreadDpiAwarenessContext</b> was never called for this thread, then the return value will equal the default <b>DPI_AWARENESS_CONTEXT</b> for the process.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT GetThreadDpiAwarenessContext();
/// <summary>Retrieves the DPI_HOSTING_BEHAVIOR from the current thread.</summary>
/// <returns>The <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_hosting_behavior">DPI_HOSTING_BEHAVIOR</a> of the current thread.</returns>
/// <remarks>This API returns the hosting behavior set by an earlier call of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddpihostingbehavior">SetThreadDpiHostingBehavior</a>, or <b>DPI_HOSTING_BEHAVIOR_DEFAULT</b> if no earlier call has been made.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.17134")]
internal static extern winmdroot.UI.HiDpi.DPI_HOSTING_BEHAVIOR GetThreadDpiHostingBehavior();
/// <summary>The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely encloses the update region of the specified window.</summary>
/// <param name="hWnd">Handle to the window whose update region is to be retrieved.</param>
/// <param name="lpRect">
/// <para>Pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that receives the coordinates, in device units, of the enclosing rectangle. An application can set this parameter to <b>NULL</b> to determine whether an update region exists for the window. If this parameter is <b>NULL</b>, <b>GetUpdateRect</b> returns nonzero if an update region exists, and zero if one does not. This provides a simple and efficient means of determining whether a <b>WM_PAINT</b> message resulted from an invalid area.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getupdaterect#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bErase">Specifies whether the background in the update region is to be erased. If this parameter is <b>TRUE</b> and the update region is not empty, <b>GetUpdateRect</b> sends a <b>WM_ERASEBKGND</b> message to the specified window to erase the background.</param>
/// <returns>
/// <para>If the update region is not empty, the return value is nonzero. If there is no update region, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The update rectangle retrieved by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> function is identical to that retrieved by <b>GetUpdateRect</b>.</para>
/// <para><a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> automatically validates the update region, so any call to <b>GetUpdateRect</b> made immediately after the call to <b>BeginPaint</b> retrieves an empty update region.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getupdaterect#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL GetUpdateRect(winmdroot.Foundation.HWND hWnd, [Optional] winmdroot.Foundation.RECT* lpRect, winmdroot.Foundation.BOOL bErase);
/// <summary>The GetUpdateRgn function retrieves the update region of a window by copying it into the specified region. The coordinates of the update region are relative to the upper-left corner of the window (that is, they are client coordinates).</summary>
/// <param name="hWnd">Handle to the window with an update region that is to be retrieved.</param>
/// <param name="hRgn">Handle to the region to receive the update region.</param>
/// <param name="bErase">Specifies whether the window background should be erased and whether nonclient areas of child windows should be drawn. If this parameter is <b>FALSE</b>, no drawing is done.</param>
/// <returns>
/// <para>The return value indicates the complexity of the resulting region; it can be one of the following values. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> function automatically validates the update region, so any call to <b>GetUpdateRgn</b> made immediately after the call to <b>BeginPaint</b> retrieves an empty update region.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Graphics.Gdi.GDI_REGION_TYPE GetUpdateRgn(winmdroot.Foundation.HWND hWnd, winmdroot.Graphics.Gdi.HRGN hRgn, winmdroot.Foundation.BOOL bErase);
/// <summary>Retrieves information about the specified window station or desktop object. (Unicode)</summary>
/// <param name="hObj">
/// <para>A handle to the window station or desktop object. This handle is returned by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowstationa">CreateWindowStation</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-openwindowstationa">OpenWindowStation</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createdesktopa">CreateDesktop</a>, or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-opendesktopa">OpenDesktop</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getuserobjectinformationw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIndex"></param>
/// <param name="pvInfo">A pointer to a buffer to receive the object information.</param>
/// <param name="nLength">The size of the buffer pointed to by the <i>pvInfo</i> parameter, in bytes.</param>
/// <param name="lpnLengthNeeded">A pointer to a variable receiving the number of bytes required to store the requested information. If this variable's value is greater than the value of the <i>nLength</i> parameter when the function returns, the function returns FALSE, and none of the information is copied to the <i>pvInfo</i> buffer. If the value of the variable pointed to by <i>lpnLengthNeeded</i> is less than or equal to the value of <i>nLength</i>, the entire information block is copied.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>> [!NOTE] > The winuser.h header defines GetUserObjectInformation as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getuserobjectinformationw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetUserObjectInformation(winmdroot.Foundation.HANDLE hObj, winmdroot.System.StationsAndDesktops.USER_OBJECT_INFORMATION_INDEX nIndex, [Optional] void* pvInfo, uint nLength, [Optional] uint* lpnLengthNeeded)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hObj, nIndex, pvInfo, nLength, lpnLengthNeeded);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetUserObjectInformationW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HANDLE hObj, winmdroot.System.StationsAndDesktops.USER_OBJECT_INFORMATION_INDEX nIndex, [Optional] void* pvInfo, uint nLength, [Optional] uint* lpnLengthNeeded);
}
/// <summary>Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to a window. The window handle retrieved is relative to this window, based on the value of the <i>uCmd</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uCmd">Type: <b>UINT</b></param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-enumchildwindows">EnumChildWindows</a> function is more reliable than calling <b>GetWindow</b> in a loop. An application that calls <b>GetWindow</b> to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND GetWindow(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.GET_WINDOW_CMD uCmd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hWnd, uCmd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetWindow"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.GET_WINDOW_CMD uCmd);
}
/// <inheritdoc cref="GetWindowDisplayAffinity(winmdroot.Foundation.HWND, uint*)"/>
[SupportedOSPlatform("windows6.1")]
internal static unsafe winmdroot.Foundation.BOOL GetWindowDisplayAffinity(winmdroot.Foundation.HWND hWnd, out uint pdwAffinity)
{
fixed (uint* pdwAffinityLocal = &pdwAffinity)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetWindowDisplayAffinity(hWnd, pdwAffinityLocal);
return __result;
}
}
/// <summary>Retrieves the current display affinity setting, from any process, for a given window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowdisplayaffinity#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pdwAffinity">
/// <para>Type: <b>DWORD*</b> A pointer to a variable that receives the display affinity setting. See <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowdisplayaffinity">SetWindowDisplayAffinity</a> for a list of affinity settings and their meanings.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowdisplayaffinity#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> This function succeeds only when the window is layered and Desktop Windows Manager is composing the desktop. If this function succeeds, it returns <b>TRUE</b>; otherwise, it returns <b>FALSE</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>This function and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowdisplayaffinity">SetWindowDisplayAffinity</a> are designed to support the window content protection feature unique to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied via a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager (DWM) is composing the desktop.</para>
/// <para>It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowdisplayaffinity">SetWindowDisplayAffinity</a> and <b>GetWindowDisplayAffinity</b>, and other necessary functions such as <a href="https://docs.microsoft.com/windows/desktop/api/dwmapi/nf-dwmapi-dwmiscompositionenabled">DwmIsCompositionEnabled</a>, will strictly protect windowed content, as in the case where someone takes a photograph of the screen.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowdisplayaffinity#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.1")]
internal static unsafe winmdroot.Foundation.BOOL GetWindowDisplayAffinity(winmdroot.Foundation.HWND hWnd, uint* pdwAffinity)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, pdwAffinity);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetWindowDisplayAffinity"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, uint* pdwAffinity);
}
/// <summary>Returns the DPI_AWARENESS_CONTEXT associated with a window.</summary>
/// <param name="hwnd">The window to query.</param>
/// <returns>The <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for the provided window. If the window is not valid, the return value is <b>NULL</b>.</returns>
/// <remarks>
/// <para><div class="alert"><b>Important</b> <p class="note">The return value of <b>GetWindowDpiAwarenessContext</b> is not affected by the <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a> of the current thread. It only indicates the context of the window specified by the <i>hwnd</i> input parameter. </div> <div> </div></para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowdpiawarenesscontext#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT GetWindowDpiAwarenessContext(winmdroot.Foundation.HWND hwnd);
/// <inheritdoc cref="GetWindowPlacement(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetWindowPlacement(winmdroot.Foundation.HWND hWnd, ref winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT lpwndpl)
{
fixed (winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndplLocal = &lpwndpl)
{
winmdroot.Foundation.BOOL __result = PInvoke.GetWindowPlacement(hWnd, lpwndplLocal);
return __result;
}
}
/// <summary>Retrieves the show state and the restored, minimized, and maximized positions of the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowplacement#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpwndpl">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a>*</b> A pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> structure that receives the show state and position information. Before calling <b>GetWindowPlacement</b>, set the <b>length</b> member to <c>sizeof(WINDOWPLACEMENT)</c>. <b>GetWindowPlacement</b> fails if <i>lpwndpl</i>-> <i>length</i> is not set correctly.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowplacement#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>flags</b> member of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> retrieved by this function is always zero. If the window identified by the <i>hWnd</i> parameter is maximized, the <b>showCmd</b> member is SW_SHOWMAXIMIZED. If the window is minimized, <b>showCmd</b> is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL. The <b>length</b> member of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> must be set to sizeof(<b>WINDOWPLACEMENT</b>). If this member is not set correctly, the function returns <b>FALSE</b>. For additional remarks on the proper use of window placement coordinates, see <b>WINDOWPLACEMENT</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getwindowplacement#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL GetWindowPlacement(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndpl)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, lpwndpl);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "GetWindowPlacement"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndpl);
}
/// <summary>Removes the caret from the screen. Hiding a caret does not destroy its current shape or invalidate the insertion point.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window that owns the caret. If this parameter is <b>NULL</b>, <b>HideCaret</b> searches the current task for the window that owns the caret.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-hidecaret#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><b>HideCaret</b> hides the caret only if the specified window owns the caret. If the specified window does not own the caret, <b>HideCaret</b> does nothing and returns <b>FALSE</b>. Hiding is cumulative. If your application calls <b>HideCaret</b> five times in a row, it must also call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-showcaret">ShowCaret</a> five times before the caret is displayed. For an example, see <a href="https://docs.microsoft.com/windows/desktop/menurc/using-carets">Hiding a Caret</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-hidecaret#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL HideCaret(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "HideCaret"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <inheritdoc cref="InvalidateRect(winmdroot.Foundation.HWND, winmdroot.Foundation.RECT*, winmdroot.Foundation.BOOL)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL InvalidateRect(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.RECT? lpRect, winmdroot.Foundation.BOOL bErase)
{
winmdroot.Foundation.RECT lpRectLocal = lpRect ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.BOOL __result = PInvoke.InvalidateRect(hWnd, lpRect.HasValue ? &lpRectLocal : null, bErase);
return __result;
}
/// <summary>The InvalidateRect function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.</summary>
/// <param name="hWnd">A handle to the window whose update region has changed. If this parameter is <b>NULL</b>, the system invalidates and redraws all windows, not just the windows for this application, and sends the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-erasebkgnd">WM_ERASEBKGND</a> and <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-ncpaint">WM_NCPAINT</a> messages before the function returns. Setting this parameter to <b>NULL</b> is not recommended.</param>
/// <param name="lpRect">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is <b>NULL</b>, the entire client area is added to the update region.</param>
/// <param name="bErase">Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter is <b>TRUE</b>, the background is erased when the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> function is called. If this parameter is <b>FALSE</b>, the background remains unchanged.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The invalidated areas accumulate in the update region until the region is processed when the next <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message occurs or until the region is validated by using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-validaterect">ValidateRect</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-validatergn">ValidateRgn</a> function. The system sends a <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message to a window whenever its update region is not empty and there are no other messages in the application queue for that window. If the <i>bErase</i> parameter is <b>TRUE</b> for any part of the update region, the background is erased in the entire region, not just in the specified part.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-invalidaterect#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL InvalidateRect(winmdroot.Foundation.HWND hWnd, [Optional] winmdroot.Foundation.RECT* lpRect, winmdroot.Foundation.BOOL bErase);
/// <summary>The InvalidateRgn function invalidates the client area within the specified region by adding it to the current update region of a window.</summary>
/// <param name="hWnd">A handle to the window with an update region that is to be modified.</param>
/// <param name="hRgn">A handle to the region to be added to the update region. The region is assumed to have client coordinates. If this parameter is <b>NULL</b>, the entire client area is added to the update region.</param>
/// <param name="bErase">Specifies whether the background within the update region should be erased when the update region is processed. If this parameter is <b>TRUE</b>, the background is erased when the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> function is called. If the parameter is <b>FALSE</b>, the background remains unchanged.</param>
/// <returns>The return value is always nonzero.</returns>
/// <remarks>
/// <para>Invalidated areas accumulate in the update region until the next <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message is processed or until the region is validated by using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-validaterect">ValidateRect</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-validatergn">ValidateRgn</a> function. The system sends a <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message to a window whenever its update region is not empty and there are no other messages in the application queue for that window. The specified region must have been created by using one of the region functions. If the <i>bErase</i> parameter is <b>TRUE</b> for any part of the update region, the background in the entire region is erased, not just in the specified part.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-invalidatergn#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL InvalidateRgn(winmdroot.Foundation.HWND hWnd, winmdroot.Graphics.Gdi.HRGN hRgn, winmdroot.Foundation.BOOL bErase);
/// <summary>Determines whether a window is a child window or descendant window of a specified parent window.</summary>
/// <param name="hWndParent">
/// <para>Type: <b>HWND</b> A handle to the parent window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-ischild#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-ischild#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window is a child or descendant window of the specified parent window, the return value is nonzero. If the window is not a child or descendant window of the specified parent window, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-ischild">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsChild(winmdroot.Foundation.HWND hWndParent, winmdroot.Foundation.HWND hWnd);
/// <inheritdoc cref="IsDialogMessage(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.MSG*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL IsDialogMessage(winmdroot.Foundation.HWND hDlg, in winmdroot.UI.WindowsAndMessaging.MSG lpMsg)
{
fixed (winmdroot.UI.WindowsAndMessaging.MSG* lpMsgLocal = &lpMsg)
{
winmdroot.Foundation.BOOL __result = PInvoke.IsDialogMessage(hDlg, lpMsgLocal);
return __result;
}
}
/// <summary>Determines whether a message is intended for the specified dialog box and, if it is, processes the message. (Unicode)</summary>
/// <param name="hDlg">
/// <para>Type: <b>HWND</b> A handle to the dialog box.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-isdialogmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpMsg">
/// <para>Type: <b>LPMSG</b> A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure that contains the message to be checked.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-isdialogmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the message has been processed, the return value is nonzero. If the message has not been processed, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>Although the <b>IsDialogMessage</b> function is intended for modeless dialog boxes, you can use it with any window that contains controls, enabling the windows to provide the same keyboard selection as is used in a dialog box. When <b>IsDialogMessage</b> processes a message, it checks for keyboard messages and converts them into selections for the corresponding dialog box. For example, the TAB key, when pressed, selects the next control or group of controls, and the DOWN ARROW key, when pressed, selects the next control in a group. Because the <b>IsDialogMessage</b> function performs all necessary translating and dispatching of messages, a message processed by <b>IsDialogMessage</b> must not be passed to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-translatemessage">TranslateMessage</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-dispatchmessage">DispatchMessage</a> function. <b>IsDialogMessage</b> sends <a href="https://docs.microsoft.com/windows/desktop/dlgbox/wm-getdlgcode">WM_GETDLGCODE</a> messages to the dialog box procedure to determine which keys should be processed. <b>IsDialogMessage</b> can send <a href="https://docs.microsoft.com/windows/desktop/dlgbox/dm-getdefid">DM_GETDEFID</a> and <a href="https://docs.microsoft.com/windows/desktop/dlgbox/dm-setdefid">DM_SETDEFID</a> messages to the window. These messages are defined in the Winuser.h header file as <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-user">WM_USER</a> and <b>WM_USER</b> + 1, so conflicts are possible with application-defined messages having the same values.</para>
/// <para>> [!NOTE] > The winuser.h header defines IsDialogMessage as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-isdialogmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "IsDialogMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL IsDialogMessage(winmdroot.Foundation.HWND hDlg, winmdroot.UI.WindowsAndMessaging.MSG* lpMsg);
/// <summary>IsProcessDPIAware may be altered or unavailable. Instead, use GetProcessDPIAwareness.</summary>
/// <returns>
/// <para>Type: <b>BOOL</b> <b>TRUE</b> if the process is dpi aware; otherwise, <b>FALSE</b>.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-isprocessdpiaware">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows6.0.6000")]
internal static extern winmdroot.Foundation.BOOL IsProcessDPIAware();
/// <summary>Determines if a specified DPI_AWARENESS_CONTEXT is valid and supported by the current system.</summary>
/// <param name="value">The context that you want to determine if it is supported.</param>
/// <returns><b>TRUE</b> if the provided context is supported, otherwise <b>FALSE</b>.</returns>
/// <remarks>
/// <para><b>IsValidDpiAwarenessContext</b> determines the validity of any provided <b>DPI_AWARENESS_CONTEXT</b>. You should make sure a context is valid before using <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddpiawarenesscontext">SetThreadDpiAwarenessContext</a> to that context. An input <i>value</i> of <b>NULL</b> is considered to be an invalid context and will result in a return value of <b>FALSE.</b></para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-isvaliddpiawarenesscontext#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.Foundation.BOOL IsValidDpiAwarenessContext(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT value);
/// <summary>Determines whether the specified window handle identifies an existing window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window handle identifies an existing window, the return value is nonzero. If the window handle does not identify an existing window, the return value is zero.</para>
/// </returns>
/// <remarks>A thread should not use <b>IsWindow</b> for a window that it did not create because the window could be destroyed after this function was called. Further, because window handles are recycled the handle could even point to a different window.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsWindow(winmdroot.Foundation.HWND hWnd);
/// <summary>Determines whether the specified window is enabled for mouse and keyboard input.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowenabled#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window is enabled, the return value is nonzero. If the window is not enabled, the return value is zero.</para>
/// </returns>
/// <remarks>A child window receives input only if it is both enabled and visible.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsWindowEnabled(winmdroot.Foundation.HWND hWnd);
/// <summary>Determines whether the specified window is a native Unicode window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowunicode#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window is a native Unicode window, the return value is nonzero. If the window is not a native Unicode window, the return value is zero. The window is a native ANSI window.</para>
/// </returns>
/// <remarks>
/// <para>The character set of a window is determined by the use of the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerclassa">RegisterClass</a> function. If the window class was registered with the ANSI version of <b>RegisterClass</b> (<b>RegisterClassA</b>), the character set of the window is ANSI. If the window class was registered with the Unicode version of <b>RegisterClass</b> (<b>RegisterClassW</b>), the character set of the window is Unicode. The system does automatic two-way translation (Unicode to ANSI) for window messages. For example, if an ANSI window message is sent to a window that uses the Unicode character set, the system translates that message into a Unicode message before calling the window procedure. The system calls <b>IsWindowUnicode</b> to determine whether to translate the message.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowunicode#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsWindowUnicode(winmdroot.Foundation.HWND hWnd);
/// <summary>Determines the visibility state of the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowvisible#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the specified window, its parent window, its parent's parent window, and so forth, have the <b>WS_VISIBLE</b> style, the return value is nonzero. Otherwise, the return value is zero. Because the return value specifies whether the window has the <b>WS_VISIBLE</b> style, it may be nonzero even if the window is totally obscured by other windows.</para>
/// </returns>
/// <remarks>
/// <para>The visibility state of a window is indicated by the <b>WS_VISIBLE</b> style bit. When <b>WS_VISIBLE</b> is set, the window is displayed and subsequent drawing into it is displayed as long as the window has the <b>WS_VISIBLE</b> style. Any drawing to a window with the <b>WS_VISIBLE</b> style will not be displayed if the window is obscured by other windows or is clipped by its parent window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iswindowvisible#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsWindowVisible(winmdroot.Foundation.HWND hWnd);
/// <summary>Determines whether a window is maximized.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be tested.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iszoomed#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window is zoomed, the return value is nonzero. If the window is not zoomed, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-iszoomed">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL IsZoomed(winmdroot.Foundation.HWND hWnd);
/// <summary>Destroys the specified timer.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window associated with the specified timer. This value must be the same as the <i>hWnd</i> value passed to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-settimer">SetTimer</a> function that created the timer.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-killtimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uIDEvent">
/// <para>Type: <b>UINT_PTR</b> The timer to be destroyed. If the window handle passed to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-settimer">SetTimer</a> is valid, this parameter must be the same as the <i>nIDEvent</i> value passed to <b>SetTimer</b>. If the application calls <b>SetTimer</b> with <i>hWnd</i> set to <b>NULL</b>, this parameter must be the timer identifier returned by <b>SetTimer</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-killtimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>The <b>KillTimer</b> function does not remove <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-timer">WM_TIMER</a> messages already posted to the message queue.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL KillTimer(winmdroot.Foundation.HWND hWnd, nuint uIDEvent)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, uIDEvent);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "KillTimer"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, nuint uIDEvent);
}
/// <inheritdoc cref="LoadCursor(winmdroot.Foundation.HINSTANCE, winmdroot.Foundation.PCWSTR)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.UI.WindowsAndMessaging.HCURSOR LoadCursor(winmdroot.Foundation.HINSTANCE hInstance, string lpCursorName)
{
fixed (char* lpCursorNameLocal = lpCursorName)
{
winmdroot.UI.WindowsAndMessaging.HCURSOR __result = PInvoke.LoadCursor(hInstance, lpCursorNameLocal);
return __result;
}
}
/// <summary>Loads the specified cursor resource from the executable (.EXE) file associated with an application instance. (Unicode)</summary>
/// <param name="hInstance">
/// <para>Type: <b>HINSTANCE</b> A handle to an instance of the module whose executable file contains the cursor to be loaded.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpCursorName">
/// <para>Type: <b>LPCTSTR</b> The name of the cursor resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-makeintresourcea">MAKEINTRESOURCE</a> macro can also be used to create this value. To use one of the predefined cursors, the application must set the <i>hInstance</i> parameter to <b>NULL</b> and the <i>lpCursorName</i> parameter to one the following values. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HCURSOR</b> If the function succeeds, the return value is the handle to the newly loaded cursor. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>LoadCursor</b> function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to the existing resource. This function returns a valid cursor handle only if the <i>lpCursorName</i> parameter is a pointer to a cursor resource. If <i>lpCursorName</i> is a pointer to any type of resource other than a cursor (such as an icon), the return value is not <b>NULL</b>, even though it is not a valid cursor handle. The <b>LoadCursor</b> function searches the cursor resource most appropriate for the cursor for the current display device. The cursor resource can be a color or monochrome bitmap. <h3><a id="DPI_Virtualization"></a><a id="dpi_virtualization"></a><a id="DPI_VIRTUALIZATION"></a>DPI Virtualization</h3> This API does not participate in DPI virtualization. The output returned is not affected by the DPI of the calling thread.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.UI.WindowsAndMessaging.HCURSOR LoadCursor(winmdroot.Foundation.HINSTANCE hInstance, winmdroot.Foundation.PCWSTR lpCursorName)
{
Marshal.SetLastSystemError(0);
winmdroot.UI.WindowsAndMessaging.HCURSOR __retVal = LocalExternFunction(hInstance, lpCursorName);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "LoadCursorW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.UI.WindowsAndMessaging.HCURSOR LocalExternFunction(winmdroot.Foundation.HINSTANCE hInstance, winmdroot.Foundation.PCWSTR lpCursorName);
}
/// <summary>Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code. (Unicode)</summary>
/// <param name="uCode">
/// <para>Type: **UINT** The [virtual key code](/windows/desktop/inputdev/virtual-key-codes) or scan code for a key. How this value is interpreted depends on the value of the *uMapType* parameter. **Starting with Windows Vista**, the high byte of the *uCode* value can contain either 0xe0 or 0xe1 to specify the extended scan code.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-mapvirtualkeyw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uMapType">
/// <para>Type: **UINT** The translation to be performed. The value of this parameter depends on the value of the *uCode* parameter. | Value | Meaning | |-------|---------| | **MAPVK\_VK\_TO\_VSC**<br>0 | The *uCode* parameter is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If there is no translation, the function returns 0. | | **MAPVK\_VSC\_TO\_VK**<br>1 | The *uCode* parameter is a scan code and is translated into a virtual-key code that does not distinguish between left- and right-hand keys. If there is no translation, the function returns 0. | | **MAPVK\_VK\_TO\_CHAR**<br>2 | The *uCode* parameter is a virtual-key code and is translated into an unshifted character value in the low order word of the return value. Dead keys (diacritics) are indicated by setting the top bit of the return value. If there is no translation, the function returns 0. See Remarks. | | **MAPVK\_VSC\_TO\_VK\_EX**<br>3 | The *uCode* parameter is a scan code and is translated into a virtual-key code that distinguishes between left- and right-hand keys. If there is no translation, the function returns 0. | | **MAPVK\_VK\_TO\_VSC\_EX**<br>4 | **Windows Vista and later:** The *uCode* parameter is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If the scan code is an extended scan code, the high byte of the *uCode* value can contain either 0xe0 or 0xe1 to specify the extended scan code. If there is no translation, the function returns 0. |</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-mapvirtualkeyw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: **UINT** The return value is either a scan code, a virtual-key code, or a character value, depending on the value of *uCode* and *uMapType*. If there is no translation, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>To specify a handle to the keyboard layout to use for translating the specified code, use the [MapVirtualKeyEx](nf-winuser-mapvirtualkeyexw.md) function. An application can use **MapVirtualKey** to translate scan codes to the virtual-key code constants **VK_SHIFT**, **VK_CONTROL**, and **VK_MENU**, and vice versa. These translations do not distinguish between the left and right instances of the SHIFT, CTRL, or ALT keys. An application can get the scan code corresponding to the left or right instance of one of these keys by calling **MapVirtualKey** with *uCode* set to one of the following virtual-key code constants: - **VK\_LSHIFT** - **VK\_RSHIFT** - **VK\_LCONTROL** - **VK\_RCONTROL** - **VK\_LMENU** - **VK\_RMENU** These left- and right-distinguishing constants are available to an application only through the [GetKeyboardState](nf-winuser-getkeyboardstate.md), [SetKeyboardState](nf-winuser-setkeyboardstate.md), [GetAsyncKeyState](nf-winuser-getasynckeystate.md), [GetKeyState](nf-winuser-getkeystate.md), [MapVirtualKey](nf-winuser-mapvirtualkeyw.md), and **MapVirtualKeyEx** functions. For list complete table of virtual key codes, see [Virtual Key Codes](/windows/win32/inputdev/virtual-key-codes). In **MAPVK\_VK\_TO\_CHAR** mode [virtual-key codes](/windows/win32/inputdev/virtual-key-codes), the 'A'..'Z' keys are translated to upper-case 'A'..'Z' characters regardless of current keyboard layout. If you want to translate a virtual-key code to the corresponding character, use the [ToUnicode](/windows/win32/api/winuser/nf-winuser-tounicode) function. > [!NOTE] > The winuser.h header defines MapVirtualKey as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-mapvirtualkeyw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "MapVirtualKeyW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern uint MapVirtualKey(uint uCode, winmdroot.UI.Input.KeyboardAndMouse.MAP_VIRTUAL_KEY_TYPE uMapType);
/// <summary>Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.</summary>
/// <param name="uType">
/// <para>The sound to be played. The sounds are set by the user through the Sound control panel application, and then stored in the registry.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messagebeep#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>After queuing the sound, the <b>MessageBeep</b> function returns control to the calling function and plays the sound asynchronously. If it cannot play the specified alert sound, <b>MessageBeep</b> attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker. The user can disable the warning beep by using the Sound control panel application. <b>Note</b> To send a beep to a remote client, use the <a href="https://docs.microsoft.com/windows/desktop/api/utilapiset/nf-utilapiset-beep">Beep</a> function. The <b>Beep</b> function is redirected to the client, whereas <b>MessageBeep</b> is not.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messagebeep#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.1.2600")]
internal static winmdroot.Foundation.BOOL MessageBeep(winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE uType)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(uType);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "MessageBeep"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE uType);
}
/// <inheritdoc cref="MessageBox(winmdroot.Foundation.HWND, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_RESULT MessageBox(winmdroot.Foundation.HWND hWnd, string lpText, string lpCaption, winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE uType)
{
fixed (char* lpCaptionLocal = lpCaption)
{
fixed (char* lpTextLocal = lpText)
{
winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_RESULT __result = PInvoke.MessageBox(hWnd, lpTextLocal, lpCaptionLocal, uType);
return __result;
}
}
}
/// <summary>Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information. The message box returns an integer value that indicates which button the user clicked. (MessageBoxW)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the owner window of the message box to be created. If this parameter is <b>NULL</b>, the message box has no owner window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messageboxw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpText">
/// <para>Type: <b>LPCTSTR</b> The message to be displayed. If the string consists of more than one line, you can separate the lines using a carriage return and/or linefeed character between each line.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messageboxw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpCaption">
/// <para>Type: <b>LPCTSTR</b> The dialog box title. If this parameter is <b>NULL</b>, the default title is <b>Error</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messageboxw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uType">
/// <para>Type: <b>UINT</b> The contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messageboxw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> If a message box has a <b>Cancel</b> button, the function returns the <b>IDCANCEL</b> value if either the ESC key is pressed or the <b>Cancel</b> button is selected. If the message box has no <b>Cancel</b> button, pressing ESC will no effect - unless an MB_OK button is present. If an MB_OK button is displayed and the user presses ESC, the return value will be <b>IDOK</b>. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. If the function succeeds, the return value is one of the following menu-item values. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The following system icons can be used in a message box by setting the <i>uType</i> parameter to the corresponding flag value. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-messageboxw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_RESULT MessageBox(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PCWSTR lpText, winmdroot.Foundation.PCWSTR lpCaption, winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE uType)
{
Marshal.SetLastSystemError(0);
winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_RESULT __retVal = LocalExternFunction(hWnd, lpText, lpCaption, uType);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "MessageBoxW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_RESULT LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PCWSTR lpText, winmdroot.Foundation.PCWSTR lpCaption, winmdroot.UI.WindowsAndMessaging.MESSAGEBOX_STYLE uType);
}
/// <inheritdoc cref="MsgWaitForMultipleObjectsEx(uint, winmdroot.Foundation.HANDLE*, uint, winmdroot.UI.WindowsAndMessaging.QUEUE_STATUS_FLAGS, winmdroot.UI.WindowsAndMessaging.MSG_WAIT_FOR_MULTIPLE_OBJECTS_EX_FLAGS)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.WAIT_EVENT MsgWaitForMultipleObjectsEx(ReadOnlySpan<winmdroot.Foundation.HANDLE> pHandles, uint dwMilliseconds, winmdroot.UI.WindowsAndMessaging.QUEUE_STATUS_FLAGS dwWakeMask, winmdroot.UI.WindowsAndMessaging.MSG_WAIT_FOR_MULTIPLE_OBJECTS_EX_FLAGS dwFlags)
{
fixed (winmdroot.Foundation.HANDLE* pHandlesLocal = pHandles)
{
winmdroot.Foundation.WAIT_EVENT __result = PInvoke.MsgWaitForMultipleObjectsEx((uint )pHandles.Length, pHandlesLocal, dwMilliseconds, dwWakeMask, dwFlags);
return __result;
}
}
/// <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.</summary>
/// <param name="nCount">The number of object handles in the array pointed to by <i>pHandles</i>. The maximum number of object handles is <b>MAXIMUM_WAIT_OBJECTS</b> minus one. If this parameter has the value zero, then the function waits only for an input event.</param>
/// <param name="pHandles">
/// <para>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.</para>
/// <para>If one of these handles is closed while the wait is still pending, the function's behavior is undefined. The handles must have the <b>SYNCHRONIZE</b> access right. For more information, see <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/standard-access-rights">Standard Access Rights</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-msgwaitformultipleobjectsex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwMilliseconds">
/// <para>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 <i>dwMilliseconds</i> is zero, the function does not enter a wait state if the criteria is not met; it always returns immediately. If <i>dwMilliseconds</i> is <b>INFINITE</b>, the function will return only when the specified objects are signaled or an I/O completion routine or APC is queued. <b>Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2: </b>The <i>dwMilliseconds</i> value does include time spent in low-power states. For example, the timeout does keep counting down while the computer is asleep. <b>Windows 8, Windows Server 2012, Windows 8.1, Windows Server 2012 R2, Windows 10 and Windows Server 2016: </b>The <i>dwMilliseconds</i> value does not include time spent in low-power states. For example, the timeout does not keep counting down while the computer is asleep.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-msgwaitformultipleobjectsex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwWakeMask">The input types for which an input event object handle will be added to the array of object handles. This parameter can be any combination of the values listed in [GetQueueStatus](/windows/win32/api/winuser/nf-winuser-getqueuestatus) *flags* parameter.</param>
/// <param name="dwFlags"></param>
/// <returns>
/// <para>If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. (Note that <b>WAIT_OBJECT_0</b> is defined as 0 and <b>WAIT_ABANDONED_0</b> is defined as 0x00000080L.) </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>The <b>MsgWaitForMultipleObjectsEx</b> function determines whether the conditions specified by <i>dwWakeMask</i> and <i>dwFlags</i> have been met. If the conditions have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses. When <i>dwFlags</i> is zero, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns the index of the first handle in the array whose object was signaled. <b>MsgWaitForMultipleObjectsEx</b> does not return if there is unread input of the specified type in the message queue after the thread has called a function to check the queue, unless you use the <b>MWMO_INPUTAVAILABLE</b> flag. This is because functions such as <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-peekmessagea">PeekMessage</a>, <a href="https://docs.microsoft.com/previous-versions/windows/desktop/fax/-mfax-faxaccountincomingarchive-getmessage-vb">GetMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/direct3d10/id3dx10threadpump-getqueuestatus">GetQueueStatus</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-waitmessage">WaitMessage</a> check the queue and then change the state information for the queue so that the input is no longer considered new. A subsequent call to <b>MsgWaitForMultipleObjectsEx</b> will not return until new input of the specified type arrives, unless you use the <b>MWMO_INPUTAVAILABLE</b> flag. If this flag is not used, the existing unread input (received prior to the last time the thread checked the queue) is ignored. The function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the system decreases the count of a semaphore object by one. For more information, see the documentation for the individual synchronization objects. The <b>MsgWaitForMultipleObjectsEx</b> function can specify handles of any of the following object types in the <i>pHandles</i> array: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-msgwaitformultipleobjectsex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.WAIT_EVENT MsgWaitForMultipleObjectsEx(uint nCount, [Optional] winmdroot.Foundation.HANDLE* pHandles, uint dwMilliseconds, winmdroot.UI.WindowsAndMessaging.QUEUE_STATUS_FLAGS dwWakeMask, winmdroot.UI.WindowsAndMessaging.MSG_WAIT_FOR_MULTIPLE_OBJECTS_EX_FLAGS dwFlags)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.WAIT_EVENT __retVal = LocalExternFunction(nCount, pHandles, dwMilliseconds, dwWakeMask, dwFlags);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "MsgWaitForMultipleObjectsEx"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.WAIT_EVENT LocalExternFunction(uint nCount, [Optional] winmdroot.Foundation.HANDLE* pHandles, uint dwMilliseconds, winmdroot.UI.WindowsAndMessaging.QUEUE_STATUS_FLAGS dwWakeMask, winmdroot.UI.WindowsAndMessaging.MSG_WAIT_FOR_MULTIPLE_OBJECTS_EX_FLAGS dwFlags);
}
/// <summary>Signals the system that a predefined event occurred. If any client applications have registered a hook function for the event, the system calls the client's hook function.</summary>
/// <param name="hwnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to the window that contains the object that generated the event.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-notifywinevent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="idObject">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">LONG</a></b> Identifies the object that generated the event. This value is either one of the predefined <a href="https://docs.microsoft.com/windows/desktop/WinAuto/object-identifiers">object identifiers</a> or a custom object ID value.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-notifywinevent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="idChild">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">LONG</a></b> Identifies whether the event was generated by an object or by a child element of the object. If this value is CHILDID_SELF, the event was generated by the object itself. If not CHILDID_SELF, this value is the child ID of the element that generated the event.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-notifywinevent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <remarks>
/// <para>Servers call this function to notify the system that an event has occurred. Microsoft Active Accessibility checks to see if any client applications have set hook procedures for the event and, if so, calls the appropriate hook procedures. If no hook procedures are registered for the event, the performance penalty for calling this function is minor. Servers call <b>NotifyWinEvent</b> to announce the event to the system after the event has occurred; they must never notify the system of an event before the event has occurred. When the client's hook procedure is called, it receives a number of parameters that describe the event and the object that generated the event. The hook procedure uses the <a href="https://docs.microsoft.com/windows/desktop/api/oleacc/nf-oleacc-accessibleobjectfromevent">AccessibleObjectFromEvent</a> function to retrieve a pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/oleacc/nn-oleacc-iaccessible">IAccessible</a> interface of the object that generated the event. Servers may receive a [WM_GETOBJECT](/windows/win32/winauto/wm-getobject) message immediately after calling this function. This can happen if there are any in-context clients that call <a href="https://docs.microsoft.com/windows/desktop/api/oleacc/nf-oleacc-accessibleobjectfromevent">AccessibleObjectFromEvent</a> in the event callback. When servers call this function, they must be ready to handle [WM_GETOBJECT](/windows/win32/winauto/wm-getobject), return an <a href="https://docs.microsoft.com/windows/desktop/api/oleacc/nn-oleacc-iaccessible">IAccessible</a> interface pointer, and handle any of the <b>IAccessible</b> methods. <b>Note to Server Developers: </b>When you call <b>NotifyWinEvent</b>, if any clients are listening for that event in-context, their event handlers, which typically send [WM_GETOBJECT](/windows/win32/winauto/wm-getobject) and call <a href="https://docs.microsoft.com/windows/desktop/api/oleacc/nn-oleacc-iaccessible">IAccessible</a> methods, will execute before <b>NotifyWinEvent</b> returns. When you call <b>NotifyWinEvent</b>, you should be prepared to handle these calls, if they occur. If you need to do extra setup to allow for this, you should do so before you call <b>NotifyWinEvent</b>, not after.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-notifywinevent#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern void NotifyWinEvent(uint @event, winmdroot.Foundation.HWND hwnd, int idObject, int idChild);
/// <summary>Maps OEMASCII codes 0 through 0x0FF into the OEM scan codes and shift states. The function provides information that allows a program to send OEM text to another program by simulating keyboard input.</summary>
/// <param name="wOemChar">
/// <para>Type: <b>WORD</b> The ASCII value of the OEM character.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-oemkeyscan#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>DWORD</b> The low-order word of the return value contains the scan code of the OEM character, and the high-order word contains the shift state, which can be a combination of the following bits. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>This function does not provide translations for characters that require CTRL+ALT or dead keys. Characters not translated by this function must be copied by simulating input using the ALT+ keypad mechanism. The NUMLOCK key must be off. This function does not provide translations for characters that cannot be typed with one keystroke using the current keyboard layout, such as characters with diacritics requiring dead keys. Characters not translated by this function may be simulated using the ALT+ keypad mechanism. The NUMLOCK key must be on. This function is implemented using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-vkkeyscana">VkKeyScan</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-oemkeyscan#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern uint OemKeyScan(ushort wOemChar);
/// <summary>Opens the desktop that receives user input.</summary>
/// <param name="dwFlags">
/// <para>This parameter can be zero or the following value. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-openinputdesktop#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="fInherit">If this value is <b>TRUE</b>, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.</param>
/// <param name="dwDesiredAccess">
/// <para>The access to the desktop. For a list of access rights, see <a href="https://docs.microsoft.com/windows/desktop/winstation/desktop-security-and-access-rights">Desktop Security and Access Rights</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-openinputdesktop#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle to the desktop that receives user input. When you are finished using the handle, call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-closedesktop">CloseDesktop</a> function to close it. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The calling process must have an associated window station, either assigned by the system when the process is created, or set by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setprocesswindowstation">SetProcessWindowStation</a> function. The window station associated with the calling process must be capable of receiving input. If the calling process is running in a disconnected session, the function returns a handle to the desktop that becomes active when the user restores the connection. An application can use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-switchdesktop">SwitchDesktop</a> function to change the input desktop. If the <i>dwDesiredAccess</i> parameter specifies the <b>READ_CONTROL</b>, <b>WRITE_DAC</b>, or <b>WRITE_OWNER</b> standard access rights, you must also request the <b>DESKTOP_READOBJECTS</b> and <b>DESKTOP_WRITEOBJECTS</b> access rights.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-openinputdesktop#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.System.StationsAndDesktops.HDESK OpenInputDesktop(winmdroot.System.StationsAndDesktops.DESKTOP_CONTROL_FLAGS dwFlags, winmdroot.Foundation.BOOL fInherit, winmdroot.System.StationsAndDesktops.DESKTOP_ACCESS_FLAGS dwDesiredAccess)
{
Marshal.SetLastSystemError(0);
winmdroot.System.StationsAndDesktops.HDESK __retVal = LocalExternFunction(dwFlags, fInherit, dwDesiredAccess);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "OpenInputDesktop"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.System.StationsAndDesktops.HDESK LocalExternFunction(winmdroot.System.StationsAndDesktops.DESKTOP_CONTROL_FLAGS dwFlags, winmdroot.Foundation.BOOL fInherit, winmdroot.System.StationsAndDesktops.DESKTOP_ACCESS_FLAGS dwDesiredAccess);
}
/// <summary>Indicates to the system that a thread has made a request to terminate (quit). It is typically used in response to a WM_DESTROY message.</summary>
/// <param name="nExitCode">
/// <para>Type: <b>int</b> The application exit code. This value is used as the <i>wParam</i> parameter of the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a> message.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postquitmessage#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <remarks>
/// <para>The <b>PostQuitMessage</b> function posts a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a> message to the thread's message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. When the thread retrieves the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-quit">WM_QUIT</a> message from its message queue, it should exit its message loop and return control to the system. The exit value returned to the system must be the <i>wParam</i> parameter of the <b>WM_QUIT</b> message.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postquitmessage#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern void PostQuitMessage(int nExitCode);
/// <summary>Posts a message to the message queue of the specified thread. It returns without waiting for the thread to process the message. (Unicode)</summary>
/// <param name="idThread">
/// <para>Type: <b>DWORD</b> The identifier of the thread to which the message is to be posted. The function fails if the specified thread does not have a message queue. The system creates a thread's message queue when the thread makes its first call to one of the User or GDI functions. For more information, see the Remarks section. Message posting is subject to UIPI. The thread of a process can post messages only to posted-message queues of threads in processes of lesser or equal integrity level. This thread must have the <b>SE_TCB_NAME</b> privilege to post a message to a thread that belongs to a process with the same locally unique identifier (LUID) but is in a different desktop. Otherwise, the function fails and returns <b>ERROR_INVALID_THREAD_ID</b>. This thread must either belong to the same desktop as the calling thread or to a process with the same LUID. Otherwise, the function fails and returns <b>ERROR_INVALID_THREAD_ID</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postthreadmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Msg">
/// <para>Type: <b>UINT</b> The type of message to be posted.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postthreadmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postthreadmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postthreadmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. <b>GetLastError</b> returns <b>ERROR_INVALID_THREAD_ID</b> if <i>idThread</i> is not a valid thread identifier, or if the thread specified by <i>idThread</i> does not have a message queue. <b>GetLastError</b> returns <b>ERROR_NOT_ENOUGH_QUOTA</b> when the message limit is hit.</para>
/// </returns>
/// <remarks>
/// <para>When a message is blocked by UIPI the last error, retrieved with <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>, is set to 5 (access denied). The thread to which the message is posted must have created a message queue, or else the call to <b>PostThreadMessage</b> fails. Use the following method to handle this situation.</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-postthreadmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL PostThreadMessage(uint idThread, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(idThread, Msg, wParam, lParam);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "PostThreadMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(uint idThread, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam);
}
/// <inheritdoc cref="RedrawWindow(winmdroot.Foundation.HWND, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.HRGN, winmdroot.Graphics.Gdi.REDRAW_WINDOW_FLAGS)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL RedrawWindow(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.RECT? lprcUpdate, winmdroot.Graphics.Gdi.HRGN hrgnUpdate, winmdroot.Graphics.Gdi.REDRAW_WINDOW_FLAGS flags)
{
winmdroot.Foundation.RECT lprcUpdateLocal = lprcUpdate ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.BOOL __result = PInvoke.RedrawWindow(hWnd, lprcUpdate.HasValue ? &lprcUpdateLocal : null, hrgnUpdate, flags);
return __result;
}
/// <summary>The RedrawWindow function updates the specified rectangle or region in a window's client area.</summary>
/// <param name="hWnd">A handle to the window to be redrawn. If this parameter is <b>NULL</b>, the desktop window is updated.</param>
/// <param name="lprcUpdate">A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure containing the coordinates, in device units, of the update rectangle. This parameter is ignored if the <i>hrgnUpdate</i> parameter identifies a region.</param>
/// <param name="hrgnUpdate">A handle to the update region. If both the <i>hrgnUpdate</i> and <i>lprcUpdate</i> parameters are <b>NULL</b>, the entire client area is added to the update region.</param>
/// <param name="flags">
/// <para>One or more redraw flags. This parameter can be used to invalidate or validate a window, control repainting, and control which windows are affected by <b>RedrawWindow</b>. The following flags are used to invalidate the window. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-redrawwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>When <b>RedrawWindow</b> is used to invalidate part of the desktop window, the desktop window does not receive a <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message. To repaint the desktop, an application uses the RDW_ERASE flag to generate a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-erasebkgnd">WM_ERASEBKGND</a> message.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL RedrawWindow(winmdroot.Foundation.HWND hWnd, [Optional] winmdroot.Foundation.RECT* lprcUpdate, winmdroot.Graphics.Gdi.HRGN hrgnUpdate, winmdroot.Graphics.Gdi.REDRAW_WINDOW_FLAGS flags);
/// <inheritdoc cref="RegisterClass(winmdroot.UI.WindowsAndMessaging.WNDCLASSW*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe ushort RegisterClass(in winmdroot.UI.WindowsAndMessaging.WNDCLASSW lpWndClass)
{
fixed (winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClassLocal = &lpWndClass)
{
ushort __result = PInvoke.RegisterClass(lpWndClassLocal);
return __result;
}
}
/// <summary>Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx function. (RegisterClassW)</summary>
/// <param name="lpWndClass">
/// <para>Type: <b>const WNDCLASS*</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-wndclassa">WNDCLASS</a> structure. You must fill the structure with the appropriate class attributes before passing it to the function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerclassw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>ATOM</b> If the function succeeds, the return value is a class atom that uniquely identifies the class being registered. This atom can only be used by the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowa">CreateWindow</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowexa">CreateWindowEx</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getclassinfoa">GetClassInfo</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getclassinfoexa">GetClassInfoEx</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-findwindowa">FindWindow</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-findwindowexa">FindWindowEx</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-unregisterclassa">UnregisterClass</a> functions and the <b>IActiveIMMap::FilterClientWindows</b> method. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If you register the window class by using <b>RegisterClassA</b>, the application tells the system that the windows of the created class expect messages with text or character parameters to use the ANSI character set; if you register it by using <b>RegisterClassW</b>, the application requests that the system pass text parameters of messages as Unicode. The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-iswindowunicode">IsWindowUnicode</a> function enables applications to query the nature of each window. For more information on ANSI and Unicode functions, see <a href="https://docs.microsoft.com/windows/desktop/Intl/conventions-for-function-prototypes">Conventions for Function Prototypes</a>. All window classes that an application registers are unregistered when it terminates. No window classes registered by a DLL are unregistered when the DLL is unloaded. A DLL must explicitly unregister its classes when it is unloaded.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerclassw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe ushort RegisterClass(winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClass)
{
Marshal.SetLastSystemError(0);
ushort __retVal = LocalExternFunction(lpWndClass);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "RegisterClassW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe ushort LocalExternFunction(winmdroot.UI.WindowsAndMessaging.WNDCLASSW* lpWndClass);
}
/// <inheritdoc cref="RegisterWindowMessage(winmdroot.Foundation.PCWSTR)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe uint RegisterWindowMessage(string lpString)
{
fixed (char* lpStringLocal = lpString)
{
uint __result = PInvoke.RegisterWindowMessage(lpStringLocal);
return __result;
}
}
/// <summary>Defines a new window message that is guaranteed to be unique throughout the system. The message value can be used when sending or posting messages. (Unicode)</summary>
/// <param name="lpString">
/// <para>Type: <b>LPCTSTR</b> The message to be registered.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerwindowmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>UINT</b> If the message is successfully registered, the return value is a message identifier in the range 0xC000 through 0xFFFF. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>RegisterWindowMessage</b> function is typically used to register messages for communicating between two cooperating applications. If two different applications register the same message string, the applications return the same message value. The message remains registered until the session ends. Only use <b>RegisterWindowMessage</b> when more than one application must process the same message. For sending private messages within a window class, an application can use any integer in the range <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-user">WM_USER</a> through 0x7FFF. (Messages in this range are private to a window class, not to an application. For example, predefined control classes such as <b>BUTTON</b>, <b>EDIT</b>, <b>LISTBOX</b>, and <b>COMBOBOX</b> may use values in this range.)</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerwindowmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static uint RegisterWindowMessage(winmdroot.Foundation.PCWSTR lpString)
{
Marshal.SetLastSystemError(0);
uint __retVal = LocalExternFunction(lpString);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "RegisterWindowMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern uint LocalExternFunction(winmdroot.Foundation.PCWSTR lpString);
}
/// <summary>Releases the mouse capture from a window in the current thread and restores normal mouse input processing.</summary>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>An application calls this function after calling the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setcapture">SetCapture</a> function.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL ReleaseCapture()
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction();
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ReleaseCapture"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction();
}
/// <summary>The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs.</summary>
/// <param name="hWnd">A handle to the window whose DC is to be released.</param>
/// <param name="hDC">A handle to the DC to be released.</param>
/// <returns>
/// <para>The return value indicates whether the DC was released. If the DC was released, the return value is 1. If the DC was not released, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The application must call the <b>ReleaseDC</b> function for each call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowdc">GetWindowDC</a> function and for each call to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getdc">GetDC</a> function that retrieves a common DC. An application cannot use the <b>ReleaseDC</b> function to release a DC that was created by calling the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-createdca">CreateDC</a> function; instead, it must use the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-deletedc">DeleteDC</a> function. <b>ReleaseDC</b> must be called from the same thread that called <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getdc">GetDC</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-releasedc#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern int ReleaseDC(winmdroot.Foundation.HWND hWnd, winmdroot.Graphics.Gdi.HDC hDC);
/// <inheritdoc cref="ScreenToClient(winmdroot.Foundation.HWND, global::System.Drawing.Point*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL ScreenToClient(winmdroot.Foundation.HWND hWnd, ref global::System.Drawing.Point lpPoint)
{
fixed (global::System.Drawing.Point* lpPointLocal = &lpPoint)
{
winmdroot.Foundation.BOOL __result = PInvoke.ScreenToClient(hWnd, lpPointLocal);
return __result;
}
}
/// <summary>The ScreenToClient function converts the screen coordinates of a specified point on the screen to client-area coordinates.</summary>
/// <param name="hWnd">A handle to the window whose client area will be used for the conversion.</param>
/// <param name="lpPoint">A pointer to a <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure that specifies the screen coordinates to be converted.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The function uses the window identified by the <i>hWnd</i> parameter and the screen coordinates given in the <a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a> structure to compute client coordinates. It then replaces the screen coordinates with the client coordinates. The new coordinates are relative to the upper-left corner of the specified window's client area. The <b>ScreenToClient</b> function assumes the specified point is in screen coordinates. All coordinates are in device units. Do not use <b>ScreenToClient</b> when in a mirroring situation, that is, when changing from left-to-right layout to right-to-left layout. Instead, use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-mapwindowpoints">MapWindowPoints</a>. For more information, see "Window Layout and Mirroring" in <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-features">Window Features</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-screentoclient#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL ScreenToClient(winmdroot.Foundation.HWND hWnd, global::System.Drawing.Point* lpPoint);
/// <inheritdoc cref="ScrollWindow(winmdroot.Foundation.HWND, int, int, winmdroot.Foundation.RECT*, winmdroot.Foundation.RECT*)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL ScrollWindow(winmdroot.Foundation.HWND hWnd, int XAmount, int YAmount, winmdroot.Foundation.RECT? lpRect, winmdroot.Foundation.RECT? lpClipRect)
{
winmdroot.Foundation.RECT lpRectLocal = lpRect ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.RECT lpClipRectLocal = lpClipRect ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.BOOL __result = PInvoke.ScrollWindow(hWnd, XAmount, YAmount, lpRect.HasValue ? &lpRectLocal : null, lpClipRect.HasValue ? &lpClipRectLocal : null);
return __result;
}
/// <summary>The ScrollWindow function scrolls the contents of the specified window's client area.</summary>
/// <param name="hWnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to the window where the client area is to be scrolled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="XAmount">
/// <para>Type: <b>int</b> Specifies the amount, in device units, of horizontal scrolling. If the window being scrolled has the <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_OWNDC</a> or <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_CLASSDC</a> style, then this parameter uses logical units rather than device units. This parameter must be a negative value to scroll the content of the window to the left.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="YAmount">
/// <para>Type: <b>int</b> Specifies the amount, in device units, of vertical scrolling. If the window being scrolled has the <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_OWNDC</a> or <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_CLASSDC</a> style, then this parameter uses logical units rather than device units. This parameter must be a negative value to scroll the content of the window up.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpRect">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a>*</b> Pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure specifying the portion of the client area to be scrolled. If this parameter is <b>NULL</b>, the entire client area is scrolled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpClipRect">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a>*</b> Pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure containing the coordinates of the clipping rectangle. Only device bits within the clipping rectangle are affected. Bits scrolled from the outside of the rectangle to the inside are painted; bits scrolled from the inside of the rectangle to the outside are not painted.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the caret is in the window being scrolled, <b>ScrollWindow</b> automatically hides the caret to prevent it from being erased and then restores the caret after the scrolling is finished. The caret position is adjusted accordingly. The area uncovered by <b>ScrollWindow</b> is not repainted, but it is combined into the window's update region. The application eventually receives a <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message notifying it that the region must be repainted. To repaint the uncovered area at the same time the scrolling is in action, call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-updatewindow">UpdateWindow</a> function immediately after calling <b>ScrollWindow</b>. If the <i>lpRect</i> parameter is <b>NULL</b>, the positions of any child windows in the window are offset by the amount specified by the <i>XAmount</i> and <i>YAmount</i> parameters; invalid (unpainted) areas in the window are also offset. <b>ScrollWindow</b> is faster when <i>lpRect</i> is <b>NULL</b>. If <i>lpRect</i> is not <b>NULL</b>, the positions of child windows are not changed and invalid areas in the window are not offset. To prevent updating problems when <i>lpRect</i> is not <b>NULL</b>, call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-updatewindow">UpdateWindow</a> to repaint the window before calling <b>ScrollWindow</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL ScrollWindow(winmdroot.Foundation.HWND hWnd, int XAmount, int YAmount, [Optional] winmdroot.Foundation.RECT* lpRect, [Optional] winmdroot.Foundation.RECT* lpClipRect)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, XAmount, YAmount, lpRect, lpClipRect);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ScrollWindow"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, int XAmount, int YAmount, [Optional] winmdroot.Foundation.RECT* lpRect, [Optional] winmdroot.Foundation.RECT* lpClipRect);
}
/// <inheritdoc cref="ScrollWindowEx(winmdroot.Foundation.HWND, int, int, winmdroot.Foundation.RECT*, winmdroot.Foundation.RECT*, winmdroot.Graphics.Gdi.HRGN, winmdroot.Foundation.RECT*, winmdroot.UI.WindowsAndMessaging.SCROLL_WINDOW_FLAGS)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe int ScrollWindowEx(winmdroot.Foundation.HWND hWnd, int dx, int dy, winmdroot.Foundation.RECT? prcScroll, winmdroot.Foundation.RECT? prcClip, winmdroot.Graphics.Gdi.HRGN hrgnUpdate, winmdroot.Foundation.RECT* prcUpdate, winmdroot.UI.WindowsAndMessaging.SCROLL_WINDOW_FLAGS flags)
{
winmdroot.Foundation.RECT prcScrollLocal = prcScroll ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.RECT prcClipLocal = prcClip ?? default(winmdroot.Foundation.RECT);
int __result = PInvoke.ScrollWindowEx(hWnd, dx, dy, prcScroll.HasValue ? &prcScrollLocal : null, prcClip.HasValue ? &prcClipLocal : null, hrgnUpdate, prcUpdate, flags);
return __result;
}
/// <summary>The ScrollWindowEx function scrolls the contents of the specified window's client area.</summary>
/// <param name="hWnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to the window where the client area is to be scrolled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dx">
/// <para>Type: <b>int</b> Specifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dy">
/// <para>Type: <b>int</b> Specifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="prcScroll">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a>*</b> Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that specifies the portion of the client area to be scrolled. If this parameter is <b>NULL</b>, the entire client area is scrolled.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="prcClip">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a>*</b> Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the coordinates of the clipping rectangle. Only device bits within the clipping rectangle are affected. Bits scrolled from the outside of the rectangle to the inside are painted; bits scrolled from the inside of the rectangle to the outside are not painted. This parameter may be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hrgnUpdate">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HRGN</a></b> Handle to the region that is modified to hold the region invalidated by scrolling. This parameter may be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="prcUpdate">
/// <para>Type: <b>LPRECT</b> Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that receives the boundaries of the rectangle invalidated by scrolling. This parameter may be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="flags">Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b></param>
/// <returns>
/// <para>Type: <b>int</b> If the function succeeds, the return value is SIMPLEREGION (rectangular invalidated region), COMPLEXREGION (nonrectangular invalidated region; overlapping rectangles), or NULLREGION (no invalidated region). If the function fails, the return value is ERROR. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the SW_INVALIDATE and SW_ERASE flags are not specified, <b>ScrollWindowEx</b> does not invalidate the area that is scrolled from. If either of these flags is set, <b>ScrollWindowEx</b> invalidates this area. The area is not updated until the application calls the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-updatewindow">UpdateWindow</a> function, calls the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-redrawwindow">RedrawWindow</a> function (specifying the RDW_UPDATENOW or RDW_ERASENOW flag), or retrieves the <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message from the application queue. If the window has the <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-styles">WS_CLIPCHILDREN</a> style, the returned areas specified by <i>hrgnUpdate</i> and <i>prcUpdate</i> represent the total area of the scrolled window that must be updated, including any areas in child windows that need updating. If the SW_SCROLLCHILDREN flag is specified, the system does not properly update the screen if part of a child window is scrolled. The part of the scrolled child window that lies outside the source rectangle is not erased and is not properly redrawn in its new destination. To move child windows that do not lie completely within the rectangle specified by <i>prcScroll</i>, use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-deferwindowpos">DeferWindowPos</a> function. The cursor is repositioned if the SW_SCROLLCHILDREN flag is set and the caret rectangle intersects the scroll rectangle. All input and output coordinates (for <i>prcScroll</i>, <i>prcClip</i>, <i>prcUpdate</i>, and <i>hrgnUpdate</i>) are determined as client coordinates, regardless of whether the window has the <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_OWNDC</a> or <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-class-styles">CS_CLASSDC</a> class style. Use the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-lptodp">LPtoDP</a> and <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-dptolp">DPtoLP</a> functions to convert to and from logical coordinates, if necessary.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-scrollwindowex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe int ScrollWindowEx(winmdroot.Foundation.HWND hWnd, int dx, int dy, [Optional] winmdroot.Foundation.RECT* prcScroll, [Optional] winmdroot.Foundation.RECT* prcClip, winmdroot.Graphics.Gdi.HRGN hrgnUpdate, [Optional] winmdroot.Foundation.RECT* prcUpdate, winmdroot.UI.WindowsAndMessaging.SCROLL_WINDOW_FLAGS flags)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ScrollWindowEx"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe int LocalExternFunction(winmdroot.Foundation.HWND hWnd, int dx, int dy, [Optional] winmdroot.Foundation.RECT* prcScroll, [Optional] winmdroot.Foundation.RECT* prcClip, winmdroot.Graphics.Gdi.HRGN hrgnUpdate, [Optional] winmdroot.Foundation.RECT* prcUpdate, winmdroot.UI.WindowsAndMessaging.SCROLL_WINDOW_FLAGS flags);
}
/// <summary>Sends a message to the specified control in a dialog box. (Unicode)</summary>
/// <param name="hDlg">
/// <para>Type: <b>HWND</b> A handle to the dialog box that contains the control.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIDDlgItem">
/// <para>Type: <b>int</b> The identifier of the control that receives the message.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Msg">
/// <para>Type: <b>UINT</b> The message to be sent. For lists of the system-provided messages, see <a href="https://docs.microsoft.com/windows/desktop/winmsg/about-messages-and-message-queues">System-Defined Messages</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> The return value specifies the result of the message processing and depends on the message sent.</para>
/// </returns>
/// <remarks>
/// <para>The <b>SendDlgItemMessage</b> function does not return until the message has been processed. Using <b>SendDlgItemMessage</b> is identical to retrieving a handle to the specified control and calling the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendmessage">SendMessage</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-senddlgitemmessagew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SendDlgItemMessageW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.LRESULT SendDlgItemMessage(winmdroot.Foundation.HWND hDlg, int nIDDlgItem, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam);
/// <inheritdoc cref="SendInput(uint, winmdroot.UI.Input.KeyboardAndMouse.INPUT*, int)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe uint SendInput(ReadOnlySpan<winmdroot.UI.Input.KeyboardAndMouse.INPUT> pInputs, int cbSize)
{
fixed (winmdroot.UI.Input.KeyboardAndMouse.INPUT* pInputsLocal = pInputs)
{
uint __result = PInvoke.SendInput((uint )pInputs.Length, pInputsLocal, cbSize);
return __result;
}
}
/// <summary>Synthesizes keystrokes, mouse motions, and button clicks.</summary>
/// <param name="cInputs">
/// <para>Type: <b>UINT</b> The number of structures in the <i>pInputs</i> array.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pInputs">
/// <para>Type: <b>LPINPUT</b> An array of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-input">INPUT</a> structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cbSize">
/// <para>Type: <b>int</b> The size, in bytes, of an <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-input">INPUT</a> structure. If <i>cbSize</i> is not the size of an <b>INPUT</b> structure, the function fails.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>UINT</b> The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. This function fails when it is blocked by UIPI. Note that neither <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> nor the return value will indicate the failure was caused by UIPI blocking.</para>
/// </returns>
/// <remarks>
/// <para>This function is subject to UIPI. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level. The <b>SendInput</b> function inserts the events in the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-input">INPUT</a> structures serially into the keyboard or mouse input stream. These events are not interspersed with other keyboard or mouse input events inserted either by the user (with the keyboard or mouse) or by calls to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-keybd_event">keybd_event</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-mouse_event">mouse_event</a>, or other calls to <b>SendInput</b>. This function does not reset the keyboard's current state. Any keys that are already pressed when the function is called might interfere with the events that this function generates. To avoid this problem, check the keyboard's state with the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getasynckeystate">GetAsyncKeyState</a> function and correct as necessary. Because the touch keyboard uses the surrogate macros defined in winnls.h to send input to the system, a listener on the keyboard event hook must decode input originating from the touch keyboard. For more information, see <a href="https://docs.microsoft.com/windows/desktop/Intl/surrogates-and-supplementary-characters">Surrogates and Supplementary Characters</a>. An accessibility application can use <b>SendInput</b> to inject keystrokes corresponding to application launch shortcut keys that are handled by the shell. This functionality is not guaranteed to work for other types of applications.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe uint SendInput(uint cInputs, winmdroot.UI.Input.KeyboardAndMouse.INPUT* pInputs, int cbSize)
{
Marshal.SetLastSystemError(0);
uint __retVal = LocalExternFunction(cInputs, pInputs, cbSize);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SendInput"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe uint LocalExternFunction(uint cInputs, winmdroot.UI.Input.KeyboardAndMouse.INPUT* pInputs, int cbSize);
}
/// <summary>Sends the specified message to a window or windows. (SendMessageCallbackW)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose window procedure will receive the message. If this parameter is <b>HWND_BROADCAST</b> ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Msg">
/// <para>Type: <b>UINT</b> The message to be sent. For lists of the system-provided messages, see <a href="https://docs.microsoft.com/windows/desktop/winmsg/about-messages-and-message-queues">System-Defined Messages</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpResultCallBack">
/// <para>Type: <b>SENDASYNCPROC</b> A pointer to a callback function that the system calls after the window procedure processes the message. For more information, see <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nc-winuser-sendasyncproc">SendAsyncProc</a>.</para>
/// <para>If <i>hWnd</i> is <b>HWND_BROADCAST</b> ((HWND)0xffff), the system calls the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nc-winuser-sendasyncproc">SendAsyncProc</a> callback function once for each top-level window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwData">
/// <para>Type: <b>ULONG_PTR</b> An application-defined value to be sent to the callback function pointed to by the <i>lpCallBack</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the target window belongs to the same thread as the caller, then the window procedure is called synchronously, and the callback function is called immediately after the window procedure returns. If the target window belongs to a different thread from the caller, then the callback function is called only when the thread that called <b>SendMessageCallback</b> also calls <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getmessage">GetMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-peekmessagea">PeekMessage</a>, or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-waitmessage">WaitMessage</a>. If you send a message in the range below <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-user">WM_USER</a> to the asynchronous message functions (<a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-postmessagea">PostMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendnotifymessagea">SendNotifyMessage</a>, and <b>SendMessageCallback</b>), its message parameters cannot include pointers. Otherwise, the operation will fail. The functions will return before the receiving thread has had a chance to process the message and the sender will free the memory before it is used. Applications that need to communicate using <b>HWND_BROADCAST</b> should use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-registerwindowmessagea">RegisterWindowMessage</a> function to obtain a unique message for inter-application communication. The system only does marshalling for system messages (those in the range 0 to (<a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-user">WM_USER</a>-1)). To send other messages (those >= <b>WM_USER</b>) to another process, you must do custom marshalling.</para>
/// <para>> [!NOTE] > The winuser.h header defines SendMessageCallback as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagecallbackw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SendMessageCallback(winmdroot.Foundation.HWND hWnd, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam, delegate *unmanaged[Stdcall]<global::Windows.Win32.Foundation.HWND,uint,nuint,global::Windows.Win32.Foundation.LRESULT,void> lpResultCallBack, nuint dwData)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, Msg, wParam, lParam, lpResultCallBack, dwData);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SendMessageCallbackW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam, delegate *unmanaged[Stdcall]<global::Windows.Win32.Foundation.HWND,uint,nuint,global::Windows.Win32.Foundation.LRESULT,void> lpResultCallBack, nuint dwData);
}
/// <summary>Sends the specified message to one or more windows. (Unicode)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window whose window procedure will receive the message. If this parameter is <b>HWND_BROADCAST</b> ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows. The function does not return until each window has timed out. Therefore, the total wait time can be up to the value of <i>uTimeout</i> multiplied by the number of top-level windows.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Msg">
/// <para>Type: <b>UINT</b> The message to be sent. For lists of the system-provided messages, see <a href="https://docs.microsoft.com/windows/desktop/winmsg/about-messages-and-message-queues">System-Defined Messages</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Any additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Any additional message-specific information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="fuFlags">Type: <b>UINT</b></param>
/// <param name="uTimeout">
/// <para>Type: <b>UINT</b> The duration of the time-out period, in milliseconds. If the message is a broadcast message, each window can use the full time-out period. For example, if you specify a five second time-out period and there are three top-level windows that fail to process the message, you could have up to a 15 second delay.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpdwResult">
/// <para>Type: <b>PDWORD_PTR</b> The result of the message processing. The value of this parameter depends on the message that is specified.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> If the function succeeds, the return value is nonzero. <b>SendMessageTimeout</b> does not provide information about individual windows timing out if <b>HWND_BROADCAST</b> is used. If the function fails or times out, the return value is 0. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. If <b>GetLastError</b> returns <b>ERROR_TIMEOUT</b>, then the function timed out. <b>Windows 2000: </b>If <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> returns 0, then the function timed out.</para>
/// </returns>
/// <remarks>
/// <para>The function calls the window procedure for the specified window and, if the specified window belongs to a different thread, does not return until the window procedure has processed the message or the specified time-out period has elapsed. If the window receiving the message belongs to the same queue as the current thread, the window procedure is called directly—the time-out value is ignored. This function considers that a thread is not responding if it has not called <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getmessage">GetMessage</a> or a similar function within five seconds. The system only does marshalling for system messages (those in the range 0 to (<a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-user">WM_USER</a>-1)). To send other messages (those >= <b>WM_USER</b>) to another process, you must do custom marshalling.</para>
/// <para>> [!NOTE] > The winuser.h header defines SendMessageTimeout as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendmessagetimeoutw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.LRESULT SendMessageTimeout(winmdroot.Foundation.HWND hWnd, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam, winmdroot.UI.WindowsAndMessaging.SEND_MESSAGE_TIMEOUT_FLAGS fuFlags, uint uTimeout, [Optional] nuint* lpdwResult)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.LRESULT __retVal = LocalExternFunction(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, lpdwResult);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SendMessageTimeoutW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.LRESULT LocalExternFunction(winmdroot.Foundation.HWND hWnd, uint Msg, winmdroot.Foundation.WPARAM wParam, winmdroot.Foundation.LPARAM lParam, winmdroot.UI.WindowsAndMessaging.SEND_MESSAGE_TIMEOUT_FLAGS fuFlags, uint uTimeout, [Optional] nuint* lpdwResult);
}
/// <summary>Activates a window. The window must be attached to the calling thread's message queue.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the top-level window to be activated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setactivewindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is the handle to the window that was previously active. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The <b>SetActiveWindow</b> function activates a window, but not if the application is in the background. The window will be brought into the foreground (top of <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-features">Z-Order</a>) if its application is in the foreground when the system activates the window. If the window identified by the <i>hWnd</i> parameter was created by the calling thread, the active window status of the calling thread is set to <i>hWnd</i>. Otherwise, the active window status of the calling thread is set to <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setactivewindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND SetActiveWindow(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetActiveWindow"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <summary>Sets the mouse capture to the specified window belonging to the current thread.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window in the current thread that is to capture the mouse.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcapture#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is a handle to the window that had previously captured the mouse. If there is no such window, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>Only the foreground window can capture the mouse. When a background window attempts to do so, the window receives messages only for mouse events that occur when the cursor hot spot is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground. When the window no longer requires all mouse input, the thread that created the window should call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-releasecapture">ReleaseCapture</a> function to release the mouse. This function cannot be used to capture mouse input meant for another process. When the mouse is captured, menu hotkeys and other keyboard accelerators do not work.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcapture#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND SetCapture(winmdroot.Foundation.HWND hWnd);
/// <summary>Sets the cursor shape.</summary>
/// <param name="hCursor">
/// <para>Type: <b>HCURSOR</b> A handle to the cursor. The cursor must have been created by either the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createcursor">CreateCursor</a> or the <a href="https://docs.microsoft.com/win32/api/winuser/nf-winuser-createiconindirect">CreateIconIndirect</a> function, or loaded by either the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-loadcursora">LoadCursor</a> or the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-loadimagea">LoadImage</a> function. If this parameter is <b>NULL</b>, the cursor is removed from the screen.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HCURSOR</b> The return value is the handle to the previous cursor, if there was one. If there was no previous cursor, the return value is <b>NULL</b>.</para>
/// </returns>
/// <remarks>
/// <para>The cursor is set only if the new cursor is different from the previous cursor; otherwise, the function returns immediately. The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window. If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to <b>NULL</b>. If the class cursor is not <b>NULL</b>, the system restores the class cursor each time the mouse is moved. The cursor is not shown on the screen if the internal cursor display count is less than zero. This occurs if the application uses the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-showcursor">ShowCursor</a> function to hide the cursor more times than to show the cursor.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursor#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.UI.WindowsAndMessaging.HCURSOR SetCursor(winmdroot.UI.WindowsAndMessaging.HCURSOR hCursor);
/// <summary>Moves the cursor to the specified screen coordinates.</summary>
/// <param name="X">
/// <para>Type: <b>int</b> The new x-coordinate of the cursor, in screen coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursorpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Y">
/// <para>Type: <b>int</b> The new y-coordinate of the cursor, in screen coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursorpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> Returns nonzero if successful or zero otherwise. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The cursor is a shared resource. A window should move the cursor only when the cursor is in the window's client area. The calling process must have <b>WINSTA_WRITEATTRIBUTES</b> access to the window station. The input desktop must be the current desktop when you call <b>SetCursorPos</b>. Call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-openinputdesktop">OpenInputDesktop</a> to determine whether the current desktop is the input desktop. If it is not, call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddesktop">SetThreadDesktop</a> with the <b>HDESK</b> returned by <b>OpenInputDesktop</b> to switch to that desktop.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursorpos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL SetCursorPos(int X, int Y)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(X, Y);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetCursorPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(int X, int Y);
}
/// <summary>Sets the keyboard focus to the specified window. The window must be attached to the calling thread's message queue.</summary>
/// <param name="hWnd">
/// <para>Type: **HWND** A handle to the window that will receive the keyboard input. If this parameter is NULL, keystrokes are ignored.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setfocus#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: **HWND** If the function succeeds, the return value is the handle to the window that previously had the keyboard focus. If the *hWnd* parameter is invalid or the window is not attached to the calling thread's message queue, the return value is NULL. To get extended error information, call [GetLastError function](../errhandlingapi/nf-errhandlingapi-getlasterror.md). Extended error ERROR_INVALID_PARAMETER (0x57) means that window is in disabled state.</para>
/// </returns>
/// <remarks>
/// <para>This function sends a [WM_KILLFOCUS](/windows/desktop/inputdev/wm-killfocus) message to the window that loses the keyboard focus and a [WM_SETFOCUS](/windows/desktop/inputdev/wm-setfocus) message to the window that receives the keyboard focus. It also activates either the window that receives the focus or the parent of the window that receives the focus. If a window is active but does not have the focus, any key pressed produces the [WM_SYSCHAR](/windows/desktop/menurc/wm-syschar), [WM_SYSKEYDOWN](/windows/desktop/inputdev/wm-syskeydown), or [WM_SYSKEYUP](/windows/desktop/inputdev/wm-syskeyup) message. If the VK_MENU key is also pressed, bit 30 of the *lParam* parameter of the message is set. Otherwise, the messages produced do not have this bit set. By using the [AttachThreadInput function](nf-winuser-attachthreadinput.md), a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window attached to another thread's message queue.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setfocus#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND SetFocus(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetFocus"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <summary>Brings the thread that created the specified window into the foreground and activates the window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window that should be activated and brought to the foreground.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setforegroundwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window was brought to the foreground, the return value is nonzero. If the window was not brought to the foreground, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The system restricts which processes can set the foreground window. A process can set the foreground window by calling **SetForegroundWindow** only if: - All of the following conditions are true: - The calling process belongs to a desktop application, not a UWP app or a Windows Store app designed for Windows 8 or 8.1. - The foreground process has not disabled calls to **SetForegroundWindow** by a previous call to the [**LockSetForegroundWindow**](nf-winuser-locksetforegroundwindow.md) function. - The foreground lock time-out has expired (see [**SPI_GETFOREGROUNDLOCKTIMEOUT** in **SystemParametersInfo**](nf-winuser-systemparametersinfoa.md#SPI_GETFOREGROUNDLOCKTIMEOUT)). - No menus are active. - Additionally, at least one of the following conditions is true: - The calling process is the foreground process. - The calling process was started by the foreground process. - There is currently no foreground window, and thus no foreground process. - The calling process received the last input event. - Either the foreground process or the calling process is being debugged. It is possible for a process to be denied the right to set the foreground window even if it meets these conditions. An application cannot force a window to the foreground while the user is working with another window. Instead, Windows flashes the taskbar button of the window to notify the user. A process that can set the foreground window can enable another process to set the foreground window by calling the [**AllowSetForegroundWindow**](nf-winuser-allowsetforegroundwindow.md) function. The process specified by the *dwProcessId* parameter to **AllowSetForegroundWindow** loses the ability to set the foreground window the next time that either the user generates input, unless the input is directed at that process, or the next time a process calls **AllowSetForegroundWindow**, unless the same process is specified as in the previous call to **AllowSetForegroundWindow**. The foreground process can disable calls to <b>SetForegroundWindow</b> by calling the [**LockSetForegroundWindow**](nf-winuser-locksetforegroundwindow.md) function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setforegroundwindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL SetForegroundWindow(winmdroot.Foundation.HWND hWnd);
/// <inheritdoc cref="SetKeyboardState(byte*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SetKeyboardState(ReadOnlySpan<byte> lpKeyState)
{
fixed (byte* lpKeyStateLocal = lpKeyState)
{
if (lpKeyState.Length < 256) throw new ArgumentException();
winmdroot.Foundation.BOOL __result = PInvoke.SetKeyboardState(lpKeyStateLocal);
return __result;
}
}
/// <summary>Copies an array of keyboard key states into the calling thread's keyboard input-state table. This is the same table accessed by the GetKeyboardState and GetKeyState functions. Changes made to this table do not affect keyboard input to any other thread.</summary>
/// <param name="lpKeyState">
/// <para>Type: <b>LPBYTE</b> A pointer to a 256-byte array that contains keyboard key states.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setkeyboardstate#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>Because the <b>SetKeyboardState</b> function alters the input state of the calling thread and not the global input state of the system, an application cannot use <b>SetKeyboardState</b> to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK (or the Japanese KANA) indicator lights on the keyboard. These can be set or cleared using <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-sendinput">SendInput</a> to simulate keystrokes.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SetKeyboardState(byte* lpKeyState)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpKeyState);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetKeyboardState"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(byte* lpKeyState);
}
/// <summary>Sets the opacity and transparency color key of a layered window.</summary>
/// <param name="hwnd">
/// <para>Type: <b>HWND</b> A handle to the layered window. A layered window is created by specifying <b>WS_EX_LAYERED</b> when creating the window with the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-createwindowexa">CreateWindowEx</a> function or by setting <b>WS_EX_LAYERED</b> via <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowlonga">SetWindowLong</a> after the window has been created. <b>Windows 8: </b>The <b>WS_EX_LAYERED</b> style is supported for top-level windows and child windows. Previous Windows versions support <b>WS_EX_LAYERED</b> only for top-level windows.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="crKey">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/gdi/colorref">COLORREF</a></b> A <a href="https://docs.microsoft.com/windows/desktop/gdi/colorref">COLORREF</a> structure that specifies the transparency color key to be used when composing the layered window. All pixels painted by the window in this color will be transparent. To generate a <b>COLORREF</b>, use the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/nf-wingdi-rgb">RGB</a> macro.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bAlpha">
/// <para>Type: <b>BYTE</b> Alpha value used to describe the opacity of the layered window. Similar to the <b>SourceConstantAlpha</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/wingdi/ns-wingdi-blendfunction">BLENDFUNCTION</a> structure. When <i>bAlpha</i> is 0, the window is completely transparent. When <i>bAlpha</i> is 255, the window is opaque.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwFlags">Type: <b>DWORD</b></param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>Note that once <b>SetLayeredWindowAttributes</b> has been called for a layered window, subsequent <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-updatelayeredwindow">UpdateLayeredWindow</a> calls will fail until the layering style bit is cleared and set again. For more information, see <a href="https://docs.microsoft.com/windows/desktop/winmsg/using-windows">Using Layered Windows</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL SetLayeredWindowAttributes(winmdroot.Foundation.HWND hwnd, winmdroot.Foundation.COLORREF crKey, byte bAlpha, winmdroot.UI.WindowsAndMessaging.LAYERED_WINDOW_ATTRIBUTES_FLAGS dwFlags)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hwnd, crKey, bAlpha, dwFlags);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetLayeredWindowAttributes"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hwnd, winmdroot.Foundation.COLORREF crKey, byte bAlpha, winmdroot.UI.WindowsAndMessaging.LAYERED_WINDOW_ATTRIBUTES_FLAGS dwFlags);
}
/// <summary>Assigns a new menu to the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to which the menu is to be assigned.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setmenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hMenu">
/// <para>Type: <b>HMENU</b> A handle to the new menu. If this parameter is <b>NULL</b>, the window's current menu is removed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setmenu#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The window is redrawn to reflect the menu change. A menu can be assigned to any window that is not a child window. The <b>SetMenu</b> function replaces the previous menu, if any, but it does not destroy it. An application should call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-destroymenu">DestroyMenu</a> function to accomplish this task.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setmenu#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL SetMenu(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.HMENU hMenu)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, hMenu);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetMenu"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.HMENU hMenu);
}
/// <summary>Changes the parent window of the specified child window.</summary>
/// <param name="hWndChild">
/// <para>Type: <b>HWND</b> A handle to the child window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setparent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWndNewParent">
/// <para>Type: <b>HWND</b> A handle to the new parent window. If this parameter is <b>NULL</b>, the desktop window becomes the new parent window. If this parameter is <b>HWND_MESSAGE</b>, the child window becomes a <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-features">message-only window</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setparent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> If the function succeeds, the return value is a handle to the previous parent window. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>An application can use the <b>SetParent</b> function to set the parent window of a pop-up, overlapped, or child window. If the window identified by the <i>hWndChild</i> parameter is visible, the system performs the appropriate redrawing and repainting. For compatibility reasons, <b>SetParent</b> does not modify the <b>WS_CHILD</b> or <b>WS_POPUP</b> window styles of the window whose parent is being changed. Therefore, if <i>hWndNewParent</i> is <b>NULL</b>, you should also clear the <b>WS_CHILD</b> bit and set the <b>WS_POPUP</b> style after calling <b>SetParent</b>. Conversely, if <i>hWndNewParent</i> is not <b>NULL</b> and the window was previously a child of the desktop, you should clear the <b>WS_POPUP</b> style and set the <b>WS_CHILD</b> style before calling <b>SetParent</b>. When you change the parent of a window, you should synchronize the UISTATE of both windows. For more information, see <a href="https://docs.microsoft.com/windows/desktop/menurc/wm-changeuistate">WM_CHANGEUISTATE</a> and <a href="https://docs.microsoft.com/windows/desktop/menurc/wm-updateuistate">WM_UPDATEUISTATE</a>. Unexpected behavior or errors may occur if <i>hWndNewParent</i> and <i>hWndChild</i> are running in different DPI awareness modes. The table below outlines this behavior: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setparent#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.HWND SetParent(winmdroot.Foundation.HWND hWndChild, winmdroot.Foundation.HWND hWndNewParent)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.HWND __retVal = LocalExternFunction(hWndChild, hWndNewParent);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetParent"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.HWND LocalExternFunction(winmdroot.Foundation.HWND hWndChild, winmdroot.Foundation.HWND hWndNewParent);
}
/// <summary>SetProcessDPIAware may be altered or unavailable. Instead, use SetProcessDPIAwareness.</summary>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. Otherwise, the return value is zero.</para>
/// </returns>
/// <remarks>For more information, see <a href="https://docs.microsoft.com/previous-versions/windows/desktop/legacy/mt846517(v=vs.85)">Setting the default DPI awareness for a process</a>.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows6.0.6000")]
internal static extern winmdroot.Foundation.BOOL SetProcessDPIAware();
/// <summary>Sets the current process to a specified dots per inch (dpi) awareness context. The DPI awareness contexts are from the DPI_AWARENESS_CONTEXT value.</summary>
/// <param name="value">A <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> handle to set.</param>
/// <returns>
/// <para>This function returns TRUE if the operation was successful, and FALSE otherwise. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. Possible errors are <b>ERROR_INVALID_PARAMETER</b> for an invalid input, and <b>ERROR_ACCESS_DENIED</b> if the default API awareness mode for the process has already been set (via a previous API call or within the application manifest).</para>
/// </returns>
/// <remarks>
/// <para>This API is a more advanced version of the previously existing <a href="https://docs.microsoft.com/windows/desktop/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness">SetProcessDpiAwareness</a> API, allowing for the process default to be set to the finer-grained <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> values. Most importantly, this allows you to programmatically set <b>Per Monitor v2</b> as the process default value, which is not possible with the previous API. This method sets the default <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for all threads within an application. Individual threads can have their DPI awareness changed from the default with the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setthreaddpiawarenesscontext">SetThreadDpiAwarenessContext</a> method. <div class="alert"><b>Important</b> <p class="note">In general, it is recommended to not use <b>SetProcessDpiAwarenessContext</b> to set the DPI awareness for your application. If possible, you should declare the DPI awareness for your application in the application manifest. For more information, see <a href="https://docs.microsoft.com/previous-versions/windows/desktop/legacy/mt846517(v=vs.85)">Setting the default DPI awareness for a process</a>. </div> <div> </div> You must call this API before you call any APIs that depend on the DPI awareness (including before creating any UI in your process). Once API awareness is set for an app, any future calls to this API will fail. This is true regardless of whether you set the DPI awareness in the manifest or by using this API. If the DPI awareness level is not set, the default value is <b>DPI_AWARENESS_CONTEXT_UNAWARE</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows10.0.15063")]
internal static winmdroot.Foundation.BOOL SetProcessDpiAwarenessContext(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT value)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(value);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetProcessDpiAwarenessContext"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT value);
}
/// <inheritdoc cref="SetScrollInfo(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS, winmdroot.UI.WindowsAndMessaging.SCROLLINFO*, winmdroot.Foundation.BOOL)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe int SetScrollInfo(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, in winmdroot.UI.WindowsAndMessaging.SCROLLINFO lpsi, winmdroot.Foundation.BOOL redraw)
{
fixed (winmdroot.UI.WindowsAndMessaging.SCROLLINFO* lpsiLocal = &lpsi)
{
int __result = PInvoke.SetScrollInfo(hwnd, nBar, lpsiLocal, redraw);
return __result;
}
}
/// <summary>The SetScrollInfo function sets the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb). The function also redraws the scroll bar, if requested.</summary>
/// <param name="hwnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the <i>fnBar</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nBar">Type: <b>int</b></param>
/// <param name="lpsi">
/// <para>Type: <b>LPCSCROLLINFO</b> Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-scrollinfo">SCROLLINFO</a> structure. Before calling <b>SetScrollInfo</b>, set the <b>cbSize</b> member of the structure to <b>sizeof</b>(<b>SCROLLINFO</b>), set the <b>fMask</b> member to indicate the parameters to set, and specify the new parameter values in the appropriate members. The</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="redraw">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> Specifies whether the scroll bar is redrawn to reflect the changes to the scroll bar. If this parameter is <b>TRUE</b>, the scroll bar is redrawn, otherwise, it is not redrawn.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollinfo#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> The return value is the current position of the scroll box.</para>
/// </returns>
/// <remarks>
/// <para>The <b>SetScrollInfo</b> function performs range checking on the values specified by the <b>nPage</b> and <b>nPos</b> members of the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-scrollinfo">SCROLLINFO</a> structure. The <b>nPage</b> member must specify a value from 0 to <b>nMax</b> - <b>nMin</b> +1. The <b>nPos</b> member must specify a value between <b>nMin</b> and <b>nMax</b> - <b>max</b>( <b>nPage</b>– 1, 0). If either value is beyond its range, the function sets it to a value that is just within the range. If the <i>fnBar</i> parameter is SB_CTL and the window specified by the <i>hwnd</i> parameter is not a system scroll bar control, the system sends the <a href="https://docs.microsoft.com/windows/desktop/Controls/sbm-setscrollinfo">SBM_SETSCROLLINFO</a> message to the window to set scroll bar information (The system can optimize the message to <a href="https://docs.microsoft.com/windows/desktop/Controls/sbm-setpos">SBM_SETPOS</a> or <a href="https://docs.microsoft.com/windows/desktop/Controls/sbm-setrange">SBM_SETRANGE</a> if the request is solely for the position or range). This allows <b>SetScrollInfo</b> to operate on a custom control that mimics a scroll bar. If the window does not handle <b>SBM_SETSCROLLINFO</b> (or the optimized <b>SBM_SETPOS</b> message or <b>SBM_SETRANGE</b> message), then the <b>SetScrollInfo</b> function fails. For an example, see <a href="https://docs.microsoft.com/windows/desktop/Controls/using-scroll-bars">Scrolling Text with the WM_PAINT Message</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollinfo#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows6.0.6000")]
internal static extern unsafe int SetScrollInfo(winmdroot.Foundation.HWND hwnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, winmdroot.UI.WindowsAndMessaging.SCROLLINFO* lpsi, winmdroot.Foundation.BOOL redraw);
/// <summary>The SetScrollPos function sets the position of the scroll box (thumb) in the specified scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box.</summary>
/// <param name="hWnd">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HWND</a></b> Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the <i>nBar</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nBar">Type: <b>int</b></param>
/// <param name="nPos">
/// <para>Type: <b>int</b> Specifies the new position of the scroll box. The position must be within the scrolling range. For more information about the scrolling range, see the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setscrollrange">SetScrollRange</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bRedraw">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> Specifies whether the scroll bar is redrawn to reflect the new scroll box position. If this parameter is <b>TRUE</b>, the scroll bar is redrawn. If it is <b>FALSE</b>, the scroll bar is not redrawn.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> If the function succeeds, the return value is the previous position of the scroll box.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the scroll bar is redrawn by a subsequent call to another function, setting the <i>bRedraw</i> parameter to <b>FALSE</b> is useful. Because the messages that indicate scroll bar position, <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-hscroll">WM_HSCROLL</a> and <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-vscroll">WM_VSCROLL</a>, are limited to 16 bits of position data, applications that rely solely on those messages for position data have a practical maximum value of 65,535 for the <b>SetScrollPos</b> function's <i>nPos</i> parameter. However, because the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setscrollinfo">SetScrollInfo</a>, <b>SetScrollPos</b>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setscrollrange">SetScrollRange</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getscrollinfo">GetScrollInfo</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getscrollpos">GetScrollPos</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getscrollrange">GetScrollRange</a> functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-hscroll">WM_HSCROLL</a> and <a href="https://docs.microsoft.com/windows/desktop/Controls/wm-vscroll">WM_VSCROLL</a> messages. See <b>GetScrollInfo</b> for a description of the technique. If the <i>nBar</i> parameter is SB_CTL and the window specified by the <i>hWnd</i> parameter is not a system scroll bar control, the system sends the <a href="https://docs.microsoft.com/windows/desktop/Controls/sbm-setpos">SBM_SETPOS</a> message to the window to set scroll bar information. This allows <b>SetScrollPos</b> to operate on a custom control that mimics a scroll bar. If the window does not handle the <b>SBM_SETPOS</b> message, the <b>SetScrollPos</b> function fails.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setscrollpos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static int SetScrollPos(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, int nPos, winmdroot.Foundation.BOOL bRedraw)
{
Marshal.SetLastSystemError(0);
int __retVal = LocalExternFunction(hWnd, nBar, nPos, bRedraw);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetScrollPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern int LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.SCROLLBAR_CONSTANTS nBar, int nPos, winmdroot.Foundation.BOOL bRedraw);
}
/// <summary>Set the DPI awareness for the current thread to the provided value.</summary>
/// <param name="dpiContext">The new <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for the current thread. This context includes the <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a> value.</param>
/// <returns>The old <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for the thread. If the <i>dpiContext</i> is invalid, the thread will not be updated and the return value will be <b>NULL</b>. You can use this value to restore the old <b>DPI_AWARENESS_CONTEXT</b> after overriding it with a predefined value.</returns>
/// <remarks>Use this API to change the <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> for the thread from the default value for the app.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.14393")]
internal static extern winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT SetThreadDpiAwarenessContext(winmdroot.UI.HiDpi.DPI_AWARENESS_CONTEXT dpiContext);
/// <summary>Sets the thread's DPI_HOSTING_BEHAVIOR. This behavior allows windows created in the thread to host child windows with a different DPI_AWARENESS_CONTEXT.</summary>
/// <param name="value">The new <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_hosting_behavior">DPI_HOSTING_BEHAVIOR</a> value for the current thread.</param>
/// <returns>The previous <a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_hosting_behavior">DPI_HOSTING_BEHAVIOR</a> for the thread. If the hosting behavior passed in is invalid, the thread will not be updated and the return value will be <b>DPI_HOSTING_BEHAVIOR_INVALID</b>. You can use this value to restore the old <b>DPI_HOSTING_BEHAVIOR</b> after overriding it with a predefined value.</returns>
/// <remarks>
/// <para><a href="https://docs.microsoft.com/windows/desktop/api/windef/ne-windef-dpi_hosting_behavior">DPI_HOSTING_BEHAVIOR</a> enables a mixed content hosting behavior, which allows parent windows created in the thread to host child windows with a different <a href="https://docs.microsoft.com/windows/desktop/hidpi/dpi-awareness-context">DPI_AWARENESS_CONTEXT</a> value. This property only effects new windows created within this thread while the mixed hosting behavior is active. A parent window with this hosting behavior is able to host child windows with different <b>DPI_AWARENESS_CONTEXT</b> values, regardless of whether the child windows have mixed hosting behavior enabled. This hosting behavior does not allow for windows with per-monitor <b>DPI_AWARENESS_CONTEXT</b> values to be hosted until windows with <b>DPI_AWARENESS_CONTEXT</b> values of system or unaware. To avoid unexpected outcomes, a thread's <b>DPI_HOSTING_BEHAVIOR</b> should be changed to support mixed hosting behaviors only when creating a new window which needs to support those behaviors. Once that window is created, the hosting behavior should be switched back to its default value. This API is used to change the thread's <b>DPI_HOSTING_BEHAVIOR</b> from its default value. This is only necessary if your app needs to host child windows from plugins and third-party components that do not support per-monitor-aware context. This is most likely to occur if you are updating complex applications to support per-monitor <b>DPI_AWARENESS_CONTEXT</b> behaviors. Enabling mixed hosting behavior will not automatically adjust the thread's <b>DPI_AWARENESS_CONTEXT</b> to be compatible with legacy content. The thread's awareness context must still be manually changed before new windows are created to host such content.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setthreaddpihostingbehavior#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows10.0.17134")]
internal static extern winmdroot.UI.HiDpi.DPI_HOSTING_BEHAVIOR SetThreadDpiHostingBehavior(winmdroot.UI.HiDpi.DPI_HOSTING_BEHAVIOR value);
/// <summary>Creates a timer with the specified time-out value.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window to be associated with the timer. This window must be owned by the calling thread. If a <b>NULL</b> value for <i>hWnd</i> is passed in along with an <i>nIDEvent</i> of an existing timer, that timer will be replaced in the same way that an existing non-NULL <i>hWnd</i> timer will be.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-settimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIDEvent">
/// <para>Type: <b>UINT_PTR</b> A nonzero timer identifier. If the <i>hWnd</i> parameter is <b>NULL</b>, and the <i>nIDEvent</i> does not match an existing timer then it is ignored and a new timer ID is generated. If the <i>hWnd</i> parameter is not <b>NULL</b> and the window specified by <i>hWnd</i> already has a timer with the value <i>nIDEvent</i>, then the existing timer is replaced by the new timer. When <b>SetTimer</b> replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. If the call is not intended to replace an existing timer, <i>nIDEvent</i> should be 0 if the <i>hWnd</i> is <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-settimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uElapse">
/// <para>Type: <b>UINT</b> The time-out value, in milliseconds. If <i>uElapse</i> is less than <b>USER_TIMER_MINIMUM</b> (0x0000000A), the timeout is set to <b>USER_TIMER_MINIMUM</b>. If <i>uElapse</i> is greater than <b>USER_TIMER_MAXIMUM</b> (0x7FFFFFFF), the timeout is set to <b>USER_TIMER_MAXIMUM</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-settimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpTimerFunc">
/// <para>Type: <b>TIMERPROC</b> A pointer to the function to be notified when the time-out value elapses. For more information about the function, see <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nc-winuser-timerproc">TimerProc</a>. If <i>lpTimerFunc</i> is <b>NULL</b>, the system posts a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-timer">WM_TIMER</a> message to the application queue. The <b>hwnd</b> member of the message's <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure contains the value of the <i>hWnd</i> parameter.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-settimer#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>UINT_PTR</b> If the function succeeds and the <i>hWnd</i> parameter is <b>NULL</b>, the return value is an integer identifying the new timer. An application can pass this value to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-killtimer">KillTimer</a> function to destroy the timer. If the function succeeds and the <i>hWnd</i> parameter is not <b>NULL</b>, then the return value is a nonzero integer. An application can pass the value of the <i>nIDEvent</i> parameter to the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-killtimer">KillTimer</a> function to destroy the timer. If the function fails to create a timer, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>An application can process <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-timer">WM_TIMER</a> messages by including a <b>WM_TIMER</b> case statement in the window procedure or by specifying a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nc-winuser-timerproc">TimerProc</a> callback function when creating the timer. When you specify a <b>TimerProc</b> callback function, the DispatchMessage calls the callback function instead of calling the window procedure when it processes <b>WM_TIMER</b> with a non-NULL lParam. Therefore, you need to dispatch messages in the calling thread, even when you use <b>TimerProc</b> instead of processing <b>WM_TIMER</b>. The <i>wParam</i> parameter of the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-timer">WM_TIMER</a> message contains the value of the <i>nIDEvent</i> parameter. The timer identifier, <i>nIDEvent</i>, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct. <b>SetTimer</b> can reuse timer IDs in the case where <i>hWnd</i> is <b>NULL</b>. Before using **SetTimer** or other timer-related functions, it is recommended to set the **UOI_TIMERPROC_EXCEPTION_SUPPRESSION** flag to **false** through the **SetUserObjectInformationW** function, otherwise the application could behave unpredictably and could be vulnerable to security exploits. For more info, see <a href="https://docs.microsoft.com/windows/win32/api/winuser/nf-winuser-setuserobjectinformationw">SetUserObjectInformationW</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-settimer#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe nuint SetTimer(winmdroot.Foundation.HWND hWnd, nuint nIDEvent, uint uElapse, delegate *unmanaged[Stdcall]<global::Windows.Win32.Foundation.HWND,uint,nuint,uint,void> lpTimerFunc)
{
Marshal.SetLastSystemError(0);
nuint __retVal = LocalExternFunction(hWnd, nIDEvent, uElapse, lpTimerFunc);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetTimer"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe nuint LocalExternFunction(winmdroot.Foundation.HWND hWnd, nuint nIDEvent, uint uElapse, delegate *unmanaged[Stdcall]<global::Windows.Win32.Foundation.HWND,uint,nuint,uint,void> lpTimerFunc);
}
/// <summary>Stores the display affinity setting in kernel mode on the hWnd associated with the window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the top-level window. The window must belong to the current process.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwAffinity">
/// <para>Type: <b>DWORD</b> The display affinity setting that specifies where the content of the window can be displayed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, it returns <b>TRUE</b>; otherwise, it returns <b>FALSE</b> when, for example, the function call is made on a non top-level window. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>This function and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowdisplayaffinity">GetWindowDisplayAffinity</a> are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM) is composing the desktop. It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using <b>SetWindowDisplayAffinity</b> and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowdisplayaffinity">GetWindowDisplayAffinity</a>, and other necessary functions such as <a href="https://docs.microsoft.com/windows/desktop/api/dwmapi/nf-dwmapi-dwmiscompositionenabled">DwmIsCompositionEnabled</a>, will strictly protect windowed content, for example where someone takes a photograph of the screen. Starting in Windows 10 Version 2004, WDA_EXCLUDEFROMCAPTURE is a supported value. Setting the display affinity to WDA_EXCLUDEFROMCAPTURE on previous version of Windows will behave as if WDA_MONITOR is applied.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowdisplayaffinity#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows6.1")]
internal static winmdroot.Foundation.BOOL SetWindowDisplayAffinity(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOW_DISPLAY_AFFINITY dwAffinity)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, dwAffinity);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowDisplayAffinity"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOW_DISPLAY_AFFINITY dwAffinity);
}
/// <inheritdoc cref="SetWindowPlacement(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SetWindowPlacement(winmdroot.Foundation.HWND hWnd, in winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT lpwndpl)
{
fixed (winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndplLocal = &lpwndpl)
{
winmdroot.Foundation.BOOL __result = PInvoke.SetWindowPlacement(hWnd, lpwndplLocal);
return __result;
}
}
/// <summary>Sets the show state and the restored, minimized, and maximized positions of the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowplacement#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpwndpl">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a>*</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> structure that specifies the new show state and window positions. Before calling <b>SetWindowPlacement</b>, set the <b>length</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> structure to sizeof(<b>WINDOWPLACEMENT</b>). <b>SetWindowPlacement</b> fails if the <b>length</b> member is not set correctly.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowplacement#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the information specified in <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> would result in a window that is completely off the screen, the system will automatically adjust the coordinates so that the window is visible, taking into account changes in screen resolution and multiple monitor configuration. The <b>length</b> member of <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-windowplacement">WINDOWPLACEMENT</a> must be set to <c>sizeof(WINDOWPLACEMENT)</c>. If this member is not set correctly, the function returns <b>FALSE</b>. For additional remarks on the proper use of window placement coordinates, see <b>WINDOWPLACEMENT</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowplacement#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SetWindowPlacement(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndpl)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, lpwndpl);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowPlacement"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOWPLACEMENT* lpwndpl);
}
/// <summary>Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWndInsertAfter">Type: <b>HWND</b></param>
/// <param name="X">
/// <para>Type: <b>int</b> The new position of the left side of the window, in client coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Y">
/// <para>Type: <b>int</b> The new position of the top of the window, in client coordinates.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cx">
/// <para>Type: <b>int</b> The new width of the window, in pixels.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cy">
/// <para>Type: <b>int</b> The new height of the window, in pixels.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uFlags">Type: <b>UINT</b></param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>As part of the Vista re-architecture, all services were moved off the interactive desktop into Session 0. hwnd and window manager operations are only effective inside a session and cross-session attempts to manipulate the hwnd will fail. For more information, see <a href="https://docs.microsoft.com/previous-versions/aa480152(v=msdn.10)">The Windows Vista Developer Story: Application Compatibility Cookbook</a>. If you have changed certain window data using <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwindowlonga">SetWindowLong</a>, you must call <b>SetWindowPos</b> for the changes to take effect. Use the following combination for <i>uFlags</i>: <c>SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED</c>. A window can be made a topmost window either by setting the <i>hWndInsertAfter</i> parameter to <b>HWND_TOPMOST</b> and ensuring that the <b>SWP_NOZORDER</b> flag is not set, or by setting a window's position in the Z order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners, however, are not changed. If neither the <b>SWP_NOACTIVATE</b> nor <b>SWP_NOZORDER</b> flag is specified (that is, when the application requests that a window be simultaneously activated and its position in the Z order changed), the value specified in <i>hWndInsertAfter</i> is used only in the following circumstances. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL SetWindowPos(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.HWND hWndInsertAfter, int X, int Y, int cx, int cy, winmdroot.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS uFlags)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowPos"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.HWND hWndInsertAfter, int X, int Y, int cx, int cy, winmdroot.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS uFlags);
}
/// <summary>The SetWindowRgn function sets the window region of a window.</summary>
/// <param name="hWnd">A handle to the window whose window region is to be set.</param>
/// <param name="hRgn">
/// <para>A handle to a region. The function sets the window region of the window to this region. If <i>hRgn</i> is <b>NULL</b>, the function sets the window region to <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowrgn#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="bRedraw">
/// <para>Specifies whether the system redraws the window after setting the window region. If <i>bRedraw</i> is <b>TRUE</b>, the system does so; otherwise, it does not. Typically, you set <i>bRedraw</i> to <b>TRUE</b> if the window is visible.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowrgn#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>When this function is called, the system sends the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-windowposchanging">WM_WINDOWPOSCHANGING</a> and <b>WM_WINDOWPOSCHANGING</b> messages to the window. The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window. <div class="alert"><b>Note</b> If the window layout is right-to-left (RTL), the coordinates are relative to the upper-right corner of the window. See <a href="https://docs.microsoft.com/windows/desktop/winmsg/window-features">Window Layout and Mirroring</a>.</div> <div> </div> After a successful call to <b>SetWindowRgn</b>, the system owns the region specified by the region handle <i>hRgn</i>. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not delete this region handle. The system deletes the region handle when it no longer needed. To obtain the window region of a window, call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowrgn">GetWindowRgn</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowrgn#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern int SetWindowRgn(winmdroot.Foundation.HWND hWnd, winmdroot.Graphics.Gdi.HRGN hRgn, winmdroot.Foundation.BOOL bRedraw);
/// <summary>Installs an application-defined hook procedure into a hook chain. (Unicode)</summary>
/// <param name="idHook">Type: <b>int</b></param>
/// <param name="lpfn">
/// <para>Type: <b>HOOKPROC</b> A pointer to the hook procedure. If the <i>dwThreadId</i> parameter is zero or specifies the identifier of a thread created by a different process, the <i>lpfn</i> parameter must point to a hook procedure in a DLL. Otherwise, <i>lpfn</i> can point to a hook procedure in the code associated with the current process.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowshookexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hmod">
/// <para>Type: <b>HINSTANCE</b> A handle to the DLL containing the hook procedure pointed to by the <i>lpfn</i> parameter. The <i>hMod</i> parameter must be set to <b>NULL</b> if the <i>dwThreadId</i> parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowshookexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwThreadId">
/// <para>Type: <b>DWORD</b> The identifier of the thread with which the hook procedure is to be associated. For desktop apps, if this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread. For Windows Store apps, see the Remarks section.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowshookexw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HHOOK</b> If the function succeeds, the return value is the handle to the hook procedure. If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><b>SetWindowsHookEx</b> can be used to inject a DLL into another process. A 32-bit DLL cannot be injected into a 64-bit process, and a 64-bit DLL cannot be injected into a 32-bit process. If an application requires the use of hooks in other processes, it is required that a 32-bit application call <b>SetWindowsHookEx</b> to inject a 32-bit DLL into 32-bit processes, and a 64-bit application call <b>SetWindowsHookEx</b> to inject a 64-bit DLL into 64-bit processes. The 32-bit and 64-bit DLLs must have different names.</para>
/// <para>Because hooks run in the context of an application, they must match the "bitness" of the application. If a 32-bit application installs a global hook on 64-bit Windows, the 32-bit hook is injected into each 32-bit process (the usual security boundaries apply). In a 64-bit process, the threads are still marked as "hooked." However, because a 32-bit application must run the hook code, the system executes the hook in the hooking app's context; specifically, on the thread that called <b>SetWindowsHookEx</b>. This means that the hooking application must continue to pump messages or it might block the normal functioning of the 64-bit processes.</para>
/// <para>If a 64-bit application installs a global hook on 64-bit Windows, the 64-bit hook is injected into each 64-bit process, while all 32-bit processes use a callback to the hooking application.</para>
/// <para>To hook all applications on the desktop of a 64-bit Windows installation, install a 32-bit global hook and a 64-bit global hook, each from appropriate processes, and be sure to keep pumping messages in the hooking application to avoid blocking normal functioning. If you already have a 32-bit global hooking application and it doesn't need to run in each application's context, you may not need to create a 64-bit version.</para>
/// <para>An error may occur if the <i>hMod</i> parameter is <b>NULL</b> and the <i>dwThreadId</i> parameter is zero or specifies the identifier of a thread created by another process. Calling the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-callnexthookex">CallNextHookEx</a> function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call <b>CallNextHookEx</b> unless you absolutely need to prevent the notification from being seen by other applications. Before terminating, an application must call the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-unhookwindowshookex">UnhookWindowsHookEx</a> function to free system resources associated with the hook. The scope of a hook depends on the hook type. Some hooks can be set only with global scope; others can also be set for only a specific thread, as shown in the following table. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowshookexw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.UI.WindowsAndMessaging.HHOOK SetWindowsHookEx(winmdroot.UI.WindowsAndMessaging.WINDOWS_HOOK_ID idHook, delegate *unmanaged[Stdcall]<int,global::Windows.Win32.Foundation.WPARAM,global::Windows.Win32.Foundation.LPARAM,global::Windows.Win32.Foundation.LRESULT> lpfn, winmdroot.Foundation.HINSTANCE hmod, uint dwThreadId)
{
Marshal.SetLastSystemError(0);
winmdroot.UI.WindowsAndMessaging.HHOOK __retVal = LocalExternFunction(idHook, lpfn, hmod, dwThreadId);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowsHookExW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.UI.WindowsAndMessaging.HHOOK LocalExternFunction(winmdroot.UI.WindowsAndMessaging.WINDOWS_HOOK_ID idHook, delegate *unmanaged[Stdcall]<int,global::Windows.Win32.Foundation.WPARAM,global::Windows.Win32.Foundation.LPARAM,global::Windows.Win32.Foundation.LRESULT> lpfn, winmdroot.Foundation.HINSTANCE hmod, uint dwThreadId);
}
/// <inheritdoc cref="SetWindowText(winmdroot.Foundation.HWND, winmdroot.Foundation.PCWSTR)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL SetWindowText(winmdroot.Foundation.HWND hWnd, string lpString)
{
fixed (char* lpStringLocal = lpString)
{
winmdroot.Foundation.BOOL __result = PInvoke.SetWindowText(hWnd, lpStringLocal);
return __result;
}
}
/// <summary>Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application. (Unicode)</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window or control whose text is to be changed.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowtextw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpString">
/// <para>Type: <b>LPCWSTR</b> The new title or control text.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowtextw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>If the target window is owned by the current process, <b>SetWindowText</b> causes a <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-settext">WM_SETTEXT</a> message to be sent to the specified window or control. If the control is a list box control created with the <b>WS_CAPTION</b> style, however, <b>SetWindowText</b> sets the text for the control, not for the list box entries. To set the text of a control in another process, send the <a href="https://docs.microsoft.com/windows/desktop/winmsg/wm-settext">WM_SETTEXT</a> message directly instead of calling <b>SetWindowText</b>. The <b>SetWindowText</b> function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowtextw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL SetWindowText(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PCWSTR lpString)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd, lpString);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowTextW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.PCWSTR lpString);
}
/// <summary>Removes an event hook function created by a previous call to SetWinEventHook.</summary>
/// <param name="hWinEventHook">
/// <para>Type: <b>HWINEVENTHOOK</b> Handle to the event hook returned in the previous call to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwineventhook">SetWinEventHook</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-unhookwinevent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">BOOL</a></b> If successful, returns <b>TRUE</b>; otherwise, returns <b>FALSE</b>. Three common errors cause this function to fail: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>This function removes the event hook specified by <i>hWinEventHook</i> that prevents the corresponding callback function from receiving further event notifications. If the client's thread ends, the system automatically calls this function. Call this function from the same thread that installed the event hook. <b>UnhookWinEvent</b> fails if called from a thread different from the call that corresponds to <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-setwineventhook">SetWinEventHook</a>. If WINEVENT_INCONTEXT was specified when this event hook was installed, the system attempts to unload the corresponding DLL from all processes that loaded it. Although unloading does not occur immediately, the hook function is not called after <b>UnhookWinEvent</b> returns. For more information on WINEVENT_INCONTEXT, see <a href="https://docs.microsoft.com/windows/desktop/WinAuto/in-context-hook-functions">In-Context Hook Functions</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-unhookwinevent#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL UnhookWinEvent(winmdroot.UI.Accessibility.HWINEVENTHOOK hWinEventHook);
/// <summary>Sets an event hook function for a range of events.</summary>
/// <param name="eventMin">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b> Specifies the <a href="https://docs.microsoft.com/windows/desktop/WinAuto/event-constants">event constant</a> for the lowest event value in the range of events that are handled by the hook function. This parameter can be set to <b>EVENT_MIN</b> to indicate the lowest possible event value.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="eventMax">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b> Specifies the event constant for the highest event value in the range of events that are handled by the hook function. This parameter can be set to <a href="https://docs.microsoft.com/windows/desktop/WinAuto/event-constants">EVENT_MAX</a> to indicate the highest possible event value.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hmodWinEventProc">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">HMODULE</a></b> Handle to the DLL that contains the hook function at <i>lpfnWinEventProc</i>, if the WINEVENT_INCONTEXT flag is specified in the <i>dwFlags</i> parameter. If the hook function is not located in a DLL, or if the WINEVENT_OUTOFCONTEXT flag is specified, this parameter is <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pfnWinEventProc">
/// <para>Type: <b>WINEVENTPROC</b> Pointer to the event hook function. For more information about this function, see <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nc-winuser-wineventproc">WinEventProc</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="idProcess">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">DWORD</a></b> Specifies the ID of the process from which the hook function receives events. Specify zero (0) to receive events from all processes on the current desktop.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="idThread">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">DWORD</a></b> Specifies the ID of the thread from which the hook function receives events. If this parameter is zero, the hook function is associated with all existing threads on the current desktop.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwFlags">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/WinProg/windows-data-types">UINT</a></b></para>
/// <para>Flag values that specify the location of the hook function and of the events to be skipped. The following flags are valid:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWINEVENTHOOK</b> If successful, returns an <a href="https://docs.microsoft.com/windows/desktop/WinAuto/hwineventhook">HWINEVENTHOOK</a> value that identifies this event hook instance. Applications save this return value to use it with the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-unhookwinevent">UnhookWinEvent</a> function. If unsuccessful, returns zero.</para>
/// </returns>
/// <remarks>
/// <para>This function allows clients to specify which processes and threads they are interested in. If the <i>idProcess</i> parameter is nonzero and <i>idThread</i> is zero, the hook function receives the specified events from all threads in that process. If the <i>idProcess</i> parameter is zero and <i>idThread</i> is nonzero, the hook function receives the specified events only from the thread specified by <i>idThread</i>. If both are zero, the hook function receives the specified events from all threads and processes. Clients can call <b>SetWinEventHook</b> multiple times if they want to register additional hook functions or listen for additional events. The client thread that calls <b>SetWinEventHook</b> must have a message loop in order to receive events. When you use <b>SetWinEventHook</b> to set a callback in managed code, you should use the <a href="https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.gchandle">GCHandle</a> structure to avoid exceptions. This tells the garbage collector not to move the callback. For out-of-context events, the event is delivered on the same thread that called <b>SetWinEventHook</b>. In some situations, even if you request WINEVENT_INCONTEXT events, the events will still be delivered out-of-context. These scenarios include events from console windows and events from processes that have a different bit-depth (64 bit versus 32 bits) than the caller.</para>
/// <para>While a hook function processes an event, additional events may be triggered, which may cause the hook function to reenter before the processing for the original event is finished. The problem with reentrancy in hook functions is that events are completed out of sequence unless the hook function handles this situation. For more information, see <a href="https://docs.microsoft.com/windows/desktop/WinAuto/guarding-against-reentrancy-in-hook-functions">Guarding Against Reentrancy</a>. <b>Windows Store app development</b> If dwFlags is WINEVENT_INCONTEXT AND (idProcess = 0 | idThread = 0), then window hook DLLs are not loaded in-process for the Windows Store app processes and the Windows Runtime broker process unless they are installed by UIAccess processes (accessibility tools). The notification is delivered on the installer's thread. This behavior is similar to what happens when there is an architecture mismatch between the hook DLL and the target application process, for example, when the hook DLL is 32-bit and the application process 64-bit.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwineventhook#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.UI.Accessibility.HWINEVENTHOOK SetWinEventHook(uint eventMin, uint eventMax, winmdroot.Foundation.HMODULE hmodWinEventProc, delegate *unmanaged[Stdcall]<global::Windows.Win32.UI.Accessibility.HWINEVENTHOOK,uint,global::Windows.Win32.Foundation.HWND,int,int,uint,uint,void> pfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);
/// <summary>Makes the caret visible on the screen at the caret's current position. When the caret becomes visible, it begins flashing automatically.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window that owns the caret. If this parameter is <b>NULL</b>, <b>ShowCaret</b> searches the current task for the window that owns the caret.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showcaret#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para><b>ShowCaret</b> shows the caret only if the specified window owns the caret, the caret has a shape, and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met, <b>ShowCaret</b> does nothing and returns <b>FALSE</b>. Hiding is cumulative. If your application calls <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-hidecaret">HideCaret</a> five times in a row, it must also call <b>ShowCaret</b> five times before the caret reappears. The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The window should destroy the caret before losing the keyboard focus or becoming inactive.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showcaret#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL ShowCaret(winmdroot.Foundation.HWND hWnd)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(hWnd);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "ShowCaret"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.Foundation.HWND hWnd);
}
/// <summary>Displays or hides the cursor. (ShowCursor)</summary>
/// <param name="bShow">
/// <para>Type: <b>BOOL</b> If <i>bShow</i> is <b>TRUE</b>, the display count is incremented by one. If <i>bShow</i> is <b>FALSE</b>, the display count is decremented by one.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showcursor#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>int</b> The return value specifies the new display counter.</para>
/// </returns>
/// <remarks>
/// <para><b>Windows 8</b>: Call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getcursorinfo">GetCursorInfo</a> to determine the cursor visibility. This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is –1.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showcursor#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern int ShowCursor(winmdroot.Foundation.BOOL bShow);
/// <summary>Sets the specified window's show state.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showwindow#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nCmdShow">Type: <b>int</b></param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the window was previously visible, the return value is nonzero. If the window was previously hidden, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>To perform certain special effects when showing or hiding a window, use <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-animatewindow">AnimateWindow</a>. The first time an application calls <b>ShowWindow</b>, it should use the <a href="https://docs.microsoft.com/windows/desktop/api/winbase/nf-winbase-winmain">WinMain</a> function's <i>nCmdShow</i> parameter as its <i>nCmdShow</i> parameter. Subsequent calls to <b>ShowWindow</b> must use one of the values in the given list, instead of the one specified by the <b>WinMain</b> function's <i>nCmdShow</i> parameter. As noted in the discussion of the <i>nCmdShow</i> parameter, the <i>nCmdShow</i> value is ignored in the first call to <b>ShowWindow</b> if the program that launched the application specifies startup information in the structure. In this case, <b>ShowWindow</b> uses the information specified in the <a href="https://docs.microsoft.com/windows/desktop/api/processthreadsapi/ns-processthreadsapi-startupinfoa">STARTUPINFO</a> structure to show the window. On subsequent calls, the application must call <b>ShowWindow</b> with <i>nCmdShow</i> set to <b>SW_SHOWDEFAULT</b> to use the startup information provided by the program that launched the application. This behavior is designed for the following situations: </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-showwindow#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL ShowWindow(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.SHOW_WINDOW_CMD nCmdShow);
/// <inheritdoc cref="TrackMouseEvent(winmdroot.UI.Input.KeyboardAndMouse.TRACKMOUSEEVENT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL TrackMouseEvent(ref winmdroot.UI.Input.KeyboardAndMouse.TRACKMOUSEEVENT lpEventTrack)
{
fixed (winmdroot.UI.Input.KeyboardAndMouse.TRACKMOUSEEVENT* lpEventTrackLocal = &lpEventTrack)
{
winmdroot.Foundation.BOOL __result = PInvoke.TrackMouseEvent(lpEventTrackLocal);
return __result;
}
}
/// <summary>Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time.</summary>
/// <param name="lpEventTrack">
/// <para>Type: <b>LPTRACKMOUSEEVENT</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-trackmouseevent">TRACKMOUSEEVENT</a> structure that contains tracking information.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-trackmouseevent#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero . If the function fails, return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>
/// <para>The mouse pointer is considered to be hovering when it stays within a specified rectangle for a specified period of time. Call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa">SystemParametersInfo</a>. and use the values <b>SPI_GETMOUSEHOVERWIDTH</b>, <b>SPI_GETMOUSEHOVERHEIGHT</b>, and <b>SPI_GETMOUSEHOVERTIME</b> to retrieve the size of the rectangle and the time. The function can post the following messages. </para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-trackmouseevent#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL TrackMouseEvent(winmdroot.UI.Input.KeyboardAndMouse.TRACKMOUSEEVENT* lpEventTrack)
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction(lpEventTrack);
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "TrackMouseEvent"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.BOOL LocalExternFunction(winmdroot.UI.Input.KeyboardAndMouse.TRACKMOUSEEVENT* lpEventTrack);
}
/// <inheritdoc cref="TranslateMDISysAccel(winmdroot.Foundation.HWND, winmdroot.UI.WindowsAndMessaging.MSG*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL TranslateMDISysAccel(winmdroot.Foundation.HWND hWndClient, in winmdroot.UI.WindowsAndMessaging.MSG lpMsg)
{
fixed (winmdroot.UI.WindowsAndMessaging.MSG* lpMsgLocal = &lpMsg)
{
winmdroot.Foundation.BOOL __result = PInvoke.TranslateMDISysAccel(hWndClient, lpMsgLocal);
return __result;
}
}
/// <summary>Processes accelerator keystrokes for window menu commands of the multiple-document interface (MDI) child windows associated with the specified MDI client window.</summary>
/// <param name="hWndClient">
/// <para>Type: <b>HWND</b> A handle to the MDI client window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-translatemdisysaccel#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpMsg">
/// <para>Type: <b>LPMSG</b> A pointer to a message retrieved by using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getmessage">GetMessage</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-peekmessagea">PeekMessage</a> function. The message must be an <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure and contain message information from the application's message queue.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-translatemdisysaccel#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the message is translated into a system command, the return value is nonzero. If the message is not translated into a system command, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-translatemdisysaccel">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL TranslateMDISysAccel(winmdroot.Foundation.HWND hWndClient, winmdroot.UI.WindowsAndMessaging.MSG* lpMsg);
/// <inheritdoc cref="TranslateMessage(winmdroot.UI.WindowsAndMessaging.MSG*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL TranslateMessage(in winmdroot.UI.WindowsAndMessaging.MSG lpMsg)
{
fixed (winmdroot.UI.WindowsAndMessaging.MSG* lpMsgLocal = &lpMsg)
{
winmdroot.Foundation.BOOL __result = PInvoke.TranslateMessage(lpMsgLocal);
return __result;
}
}
/// <summary>Translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function.</summary>
/// <param name="lpMsg">
/// <para>Type: <b>const <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a>*</b> A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/winuser/ns-winuser-msg">MSG</a> structure that contains message information retrieved from the calling thread's message queue by using the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getmessage">GetMessage</a> or <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-peekmessagea">PeekMessage</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-translatemessage#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> If the message is translated (that is, a character message is posted to the thread's message queue), the return value is nonzero. If the message is <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keydown">WM_KEYDOWN</a>, <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keyup">WM_KEYUP</a>, <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-syskeydown">WM_SYSKEYDOWN</a>, or <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-syskeyup">WM_SYSKEYUP</a>, the return value is nonzero, regardless of the translation. If the message is not translated (that is, a character message is not posted to the thread's message queue), the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <b>TranslateMessage</b> function does not modify the message pointed to by the <i>lpMsg</i> parameter.</para>
/// <para><a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keydown">WM_KEYDOWN</a> and <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keyup">WM_KEYUP</a> combinations produce a <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-char">WM_CHAR</a> or <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-deadchar">WM_DEADCHAR</a> message. <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-syskeydown">WM_SYSKEYDOWN</a> and <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-syskeyup">WM_SYSKEYUP</a> combinations produce a <a href="https://docs.microsoft.com/windows/desktop/menurc/wm-syschar">WM_SYSCHAR</a> or <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-sysdeadchar">WM_SYSDEADCHAR</a> message. <b>TranslateMessage</b> produces <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-char">WM_CHAR</a> messages only for keys that are mapped to ASCII characters by the keyboard driver. If applications process virtual-key messages for some other purpose, they should not call <b>TranslateMessage</b>. For instance, an application should not call <b>TranslateMessage</b> if the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-translateacceleratora">TranslateAccelerator</a> function returns a nonzero value. Note that the application is responsible for retrieving and dispatching input messages to the dialog box. Most applications use the main message loop for this. However, to permit the user to move to and to select controls by using the keyboard, the application must call <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-isdialogmessagea">IsDialogMessage</a>. For more information, see <a href="https://docs.microsoft.com/windows/desktop/dlgbox/dlgbox-programming-considerations">Dialog Box Keyboard Interface</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-translatemessage#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL TranslateMessage(winmdroot.UI.WindowsAndMessaging.MSG* lpMsg);
/// <summary>The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty.</summary>
/// <param name="hWnd">Handle to the window to be updated.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-updatewindow">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.BOOL UpdateWindow(winmdroot.Foundation.HWND hWnd);
/// <inheritdoc cref="ValidateRect(winmdroot.Foundation.HWND, winmdroot.Foundation.RECT*)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.BOOL ValidateRect(winmdroot.Foundation.HWND hWnd, winmdroot.Foundation.RECT? lpRect)
{
winmdroot.Foundation.RECT lpRectLocal = lpRect ?? default(winmdroot.Foundation.RECT);
winmdroot.Foundation.BOOL __result = PInvoke.ValidateRect(hWnd, lpRect.HasValue ? &lpRectLocal : null);
return __result;
}
/// <summary>The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window.</summary>
/// <param name="hWnd">Handle to the window whose update region is to be modified. If this parameter is <b>NULL</b>, the system invalidates and redraws all windows and sends the <b>WM_ERASEBKGND</b> and <b>WM_NCPAINT</b> messages to the window procedure before the function returns.</param>
/// <param name="lpRect">Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure that contains the client coordinates of the rectangle to be removed from the update region. If this parameter is <b>NULL</b>, the entire client area is removed.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-beginpaint">BeginPaint</a> function automatically validates the entire client area. Neither the <b>ValidateRect</b> nor <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-validatergn">ValidateRgn</a> function should be called if a portion of the update region must be validated before the next <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> message is generated. The system continues to generate <a href="https://docs.microsoft.com/windows/desktop/gdi/wm-paint">WM_PAINT</a> messages until the current update region is validated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-validaterect#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.BOOL ValidateRect(winmdroot.Foundation.HWND hWnd, [Optional] winmdroot.Foundation.RECT* lpRect);
/// <summary>Translates a character to the corresponding virtual-key code and shift state for the current keyboard. (Unicode)</summary>
/// <param name="ch">
/// <para>Type: <b>TCHAR</b> The character to be translated into a virtual-key code.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-vkkeyscanw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>SHORT</b> If the function succeeds, the low-order byte of the return value contains the virtual-key code and the high-order byte contains the shift state, which can be a combination of the following flag bits. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>For keyboard layouts that use the right-hand ALT key as a shift key (for example, the French keyboard layout), the shift state is represented by the value 6, because the right-hand ALT key is converted internally into CTRL+ALT. Translations for the numeric keypad (<b>VK_NUMPAD0</b> through <b>VK_DIVIDE</b>) are ignored. This function is intended to translate characters into keystrokes from the main keyboard section only. For example, the character "7" is translated into VK_7, not VK_NUMPAD7. <b>VkKeyScan</b> is used by applications that send characters by using the <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keyup">WM_KEYUP</a> and <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-keydown">WM_KEYDOWN</a> messages.</para>
/// <para>> [!NOTE] > The winuser.h header defines VkKeyScan as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-vkkeyscanw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "VkKeyScanW", CharSet = CharSet.Unicode),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern short VkKeyScan(char ch);
/// <summary>Yields control to other threads when a thread has no other messages in its message queue. The WaitMessage function suspends the thread and does not return until a new message is placed in the thread's message queue.</summary>
/// <returns>
/// <para>Type: <b>BOOL</b> If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>.</para>
/// </returns>
/// <remarks>Note that <b>WaitMessage</b> does not return if there is unread input in the message queue after the thread has called a function to check the queue. This is because functions such as <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-peekmessagea">PeekMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getmessage">GetMessage</a>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getqueuestatus">GetQueueStatus</a>, <b>WaitMessage</b>, <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-msgwaitformultipleobjects">MsgWaitForMultipleObjects</a>, and <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-msgwaitformultipleobjectsex">MsgWaitForMultipleObjectsEx</a> check the queue and then change the state information for the queue so that the input is no longer considered new. A subsequent call to <b>WaitMessage</b> will not return until new input of the specified type arrives. The existing unread input (received prior to the last time the thread checked the queue) is ignored.</remarks>
[SupportedOSPlatform("windows5.0")]
internal static winmdroot.Foundation.BOOL WaitMessage()
{
Marshal.SetLastSystemError(0);
winmdroot.Foundation.BOOL __retVal = LocalExternFunction();
Marshal.SetLastPInvokeError(Marshal.GetLastSystemError());
return __retVal;
[DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "WaitMessage"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern winmdroot.Foundation.BOOL LocalExternFunction();
}
/// <summary>Retrieves a handle to the window that contains the specified point.</summary>
/// <param name="Point">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/win32/api/windef/ns-windef-point">POINT</a></b> The point to be checked.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-windowfrompoint#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HWND</b> The return value is a handle to the window that contains the point. If no window exists at the given point, the return value is <b>NULL</b>. If the point is over a static text control, the return value is a handle to the window under the static text control.</para>
/// </returns>
/// <remarks>The <b>WindowFromPoint</b> function does not retrieve a handle to a hidden or disabled window, even if the point is within the window. An application should use the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-childwindowfrompoint">ChildWindowFromPoint</a> function for a nonrestrictive search.</remarks>
[DllImport("USER32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern winmdroot.Foundation.HWND WindowFromPoint(global::System.Drawing.Point Point);
}
}
|