From 47599ad6f2202f43d21db7db8a025f03f147cac1 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 5 Feb 2019 14:13:14 -0700 Subject: [PATCH] Added video, accelerator, caret, coordinate space, paint and RECT functions --- PInvoke/User32.Gdi/TvOut.cs | 287 +++++ PInvoke/User32.Gdi/WinUser.Accelerator.cs | 271 +++++ PInvoke/User32.Gdi/WinUser.Caret.cs | 270 +++++ PInvoke/User32.Gdi/WinUser.CoordSpace.cs | 201 ++++ PInvoke/User32.Gdi/WinUser.Paint.cs | 1867 +++++++++++++++++++++++++++++ PInvoke/User32.Gdi/WinUser.Rect.cs | 307 +++++ 6 files changed, 3203 insertions(+) create mode 100644 PInvoke/User32.Gdi/TvOut.cs create mode 100644 PInvoke/User32.Gdi/WinUser.Accelerator.cs create mode 100644 PInvoke/User32.Gdi/WinUser.Caret.cs create mode 100644 PInvoke/User32.Gdi/WinUser.CoordSpace.cs create mode 100644 PInvoke/User32.Gdi/WinUser.Paint.cs create mode 100644 PInvoke/User32.Gdi/WinUser.Rect.cs diff --git a/PInvoke/User32.Gdi/TvOut.cs b/PInvoke/User32.Gdi/TvOut.cs new file mode 100644 index 00000000..60770610 --- /dev/null +++ b/PInvoke/User32.Gdi/TvOut.cs @@ -0,0 +1,287 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// Specifies whether to retrieve or set the values that are indicated by the other members of . + [PInvokeData("Tvout.h")] + public enum VP_COMMAND : uint + { + /// Gets current video capabilities. If capability is not supported, dwFlags is 0. + VP_COMMAND_GET = 0x0001, + + /// Sets video parameters. + VP_COMMAND_SET = 0x0002, + } + + /// The copy protection command. + [PInvokeData("Tvout.h")] + public enum VP_CP_CMD : uint + { + /// Activate copy protection. + VP_CP_CMD_ACTIVATE = 0x0001, + + /// Deactivate copy protection. + VP_CP_CMD_DEACTIVATE = 0x0002, + + /// Change copy protection. + VP_CP_CMD_CHANGE = 0x0004, + } + + /// The copy protection type. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + [PInvokeData("Tvout.h")] + public enum VP_CP_TYPE : uint + { + /// Only DVD trigger bits available. + VP_CP_TYPE_APS_TRIGGER = 0x0001, + + /// Full Macrovision data is available. + VP_CP_TYPE_MACROVISION = 0x0002, + } + + /// + /// Indicates which fields of contain valid data. For VP_COMMAND_GET, this should be zero. For + /// VP_COMMAND_SET, these are the fields to set. + /// + [PInvokeData("Tvout.h")] + public enum VP_FLAGS : uint + { + /// dwMode (for VP_COMMAND_GET and VP_COMMAND_SET) and dwAvailableModes (for VP_COMMAND_GET). + VP_FLAGS_TV_MODE = 0x0001, + + /// dwTVStandard (for VP_COMMAND_GET and VP_COMMAND_SET) and dwAvailableTVStandard (for VP_COMMAND_GET). + VP_FLAGS_TV_STANDARD = 0x0002, + + /// dwFlickerFilter (for VP_COMMAND_GET and VP_COMMAND_SET). + VP_FLAGS_FLICKER = 0x0004, + + /// dwOverScanX, dwOverScanY (for VP_COMMAND_GET and VP_COMMAND_SET). + VP_FLAGS_OVERSCAN = 0x0008, + + /// dwMaxUnscaledX, dwMaxUnscaledY (for VP_COMMAND_GET). + VP_FLAGS_MAX_UNSCALED = 0x0010, + + /// dwPositionX, dwPositionY (for VP_COMMAND_GET and VP_COMMAND_SET). + VP_FLAGS_POSITION = 0x0020, + + /// dwBrightness (for VP_COMMAND_GET and VP_COMMAND_SET). + VP_FLAGS_BRIGHTNESS = 0x0040, + + /// dwContrast (for VP_COMMAND_GET and VP_COMMAND_SET). + VP_FLAGS_CONTRAST = 0x0080, + + /// + /// dwCPType (for VP_COMMAND_GET and VP_COMMAND_SET), dwCPCommand (for VP_COMMAND_SET), dwCPStandard (for VP_COMMAND_GET), + /// dwCPKey (for VP_COMMAND_SET), bCP_APSTriggerBits, bOEMCopyProtection (for VP_COMMAND_GET and VP_COMMAND_SET). + /// + VP_FLAGS_COPYPROTECT = 0x0100, + } + + /// The current playback mode. This member is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + [PInvokeData("Tvout.h")] + public enum VP_MODE : uint + { + /// + /// Describes a set of display settings that are optimal for Windows display, with the flicker filter on and any overscan display off. + /// + VP_MODE_WIN_GRAPHICS = 0x0001, + + /// + /// Describes a set of display settings for video playback, with the flicker filter off and the overscan display on. + /// + VP_MODE_TV_PLAYBACK = 0x0002, + } + + /// The TV standard. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + [PInvokeData("Tvout.h")] + public enum VP_TV : uint + { + /// NTSC m + VP_TV_STANDARD_NTSC_M = 0x0001, + + /// NTSC m j + VP_TV_STANDARD_NTSC_M_J = 0x0002, + + /// pal b + VP_TV_STANDARD_PAL_B = 0x0004, + + /// pal d + VP_TV_STANDARD_PAL_D = 0x0008, + + /// pal h + VP_TV_STANDARD_PAL_H = 0x0010, + + /// pal i + VP_TV_STANDARD_PAL_I = 0x0020, + + /// pal m + VP_TV_STANDARD_PAL_M = 0x0040, + + /// pal n + VP_TV_STANDARD_PAL_N = 0x0080, + + /// secam b + VP_TV_STANDARD_SECAM_B = 0x0100, + + /// secam d + VP_TV_STANDARD_SECAM_D = 0x0200, + + /// secam g + VP_TV_STANDARD_SECAM_G = 0x0400, + + /// secam h + VP_TV_STANDARD_SECAM_H = 0x0800, + + /// secam k + VP_TV_STANDARD_SECAM_K = 0x1000, + + /// secam k1 + VP_TV_STANDARD_SECAM_K1 = 0x2000, + + /// secam l + VP_TV_STANDARD_SECAM_L = 0x4000, + + /// win vga + VP_TV_STANDARD_WIN_VGA = 0x8000, + + /// NTSC 433 + VP_TV_STANDARD_NTSC_433 = 0x00010000, + + /// pal g + VP_TV_STANDARD_PAL_G = 0x00020000, + + /// pal 60 + VP_TV_STANDARD_PAL_60 = 0x00040000, + + /// secam l1 + VP_TV_STANDARD_SECAM_L1 = 0x00080000, + } + + /// The VIDEOPARAMETERS structure contains information for a video connection. + // https://docs.microsoft.com/en-us/previous-versions//dd145196(v=vs.85) typedef struct _VIDEOPARAMETERS { GUID guid; ULONG dwOffset; + // ULONG dwCommand; ULONG dwFlags; ULONG dwMode; ULONG dwTVStandard; ULONG dwAvailableModes; ULONG dwAvailableTVStandard; ULONG + // dwFlickerFilter; ULONG dwOverScanX; ULONG dwOverScanY; ULONG dwMaxUnscaledX; ULONG dwMaxUnscaledY; ULONG dwPositionX; ULONG + // dwPositionY; ULONG dwBrightness; ULONG dwContrast; ULONG dwCPType; ULONG dwCPCommand; ULONG dwCPStandard; ULONG dwCPKey; ULONG + // bCP_APSTriggerBits; UCHAR bOEMCopyProtection[256]; } VIDOEPARAMETERS, *PVIDEOPARAMETERS; + [PInvokeData("Tvout.h")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public struct VIDEOPARAMETERS + { + /// + /// The GUID for this structure. {02C62061-1097-11d1-920F-00A024DF156E}. Display drivers should verify the GUID at the start of + /// the structure before processing the structure. + /// + public Guid guid; + + /// Reserved; must be zero. + public uint dwOffset; + + /// Specifies whether to retrieve or set the values that are indicated by the other members of this structure. + public VP_COMMAND dwCommand; + + /// + /// Indicates which fields contain valid data. For VP_COMMAND_GET, this should be zero. For VP_COMMAND_SET, these are the fields + /// to set. + /// + public VP_FLAGS dwFlags; + + /// The current playback mode. This member is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + public VP_MODE dwMode; + + /// The TV standard. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + public VP_TV dwTVStandard; + + /// + /// Specifies which modes are available. This is valid only for VP_COMMAND_GET. It can be any combination of the values specified + /// in dwMode. + /// + public VP_MODE dwAvailableModes; + + /// + /// The TV standards that are available. This is valid only for VP_COMMAND_GET. It can be any combination of the values specified + /// in dwTVStandard. + /// + public VP_TV dwAvailableTVStandard; + + /// + /// The flicker reduction provided by the hardware. This is a percentage value in tenths of a percent, from 0 to 1,000, where 0 + /// is no flicker reduction and 1,000 is maximum flicker reduction. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwFlickerFilter; + + /// + /// The amount of overscan in the horizontal direction. This is a percentage value in tenths of a percent, from 0 to 1,000. A + /// value of 0 indicates no overscan, ensuring that the entire display is visible. A value of 1,000 is maximum overscan and + /// typically causes some of the image to be off the edge of the screen. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwOverScanX; + + /// + /// The amount of overscan in the vertical direction. This is a percentage value in tenths of a percent, from 0 to 1,000. A value + /// of 0 indicates no overscan, ensuring that the entire display is visible. A value of 1,000 is maximum overscan and typically + /// causes some of the image to be off the edge of the screen. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwOverScanY; + + /// + /// The maximum horizontal resolution, in pixels, that is supported when the video is not scaled. This field is valid for both VP_COMMAND_GET. + /// + public uint dwMaxUnscaledX; + + /// + /// The maximum vertical resolution, in pixels, that is supported when the video is not scaled. This field is valid for both VP_COMMAND_GET. + /// + public uint dwMaxUnscaledY; + + /// + /// The horizontal adjustment to the center of the image. Units are in pixels. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwPositionX; + + /// + /// The vertical adjustment to the center of the image. Units are in scan lines. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwPositionY; + + /// + /// Adjustment to the DC offset of the video signal to increase brightness on the television. It is a percentage value, 0 to 100, + /// where 0 means no adjustment and 100 means maximum adjustment. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + public uint dwBrightness; + + /// + /// Adjustment to the gain of the video signal to increase the intensity of whiteness on the television. It is a percentage + /// value, 0 to 100, where 0 means no adjustment and 100 means maximum adjustment. This field is valid for both VP_COMMAND_GET + /// and VP_COMMAND_SET. + /// + public uint dwContrast; + + /// The copy protection type. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + public VP_CP_TYPE dwCPType; + + /// The copy protection command. This field is only valid for VP_COMMAND_SET. + public VP_CP_CMD dwCPCommand; + + /// Specifies TV standards for which copy protection types are available. This field is valid only for VP_COMMAND_GET. + public uint dwCPStandard; + + /// + /// The copy protection key returned if dwCPCommand is set to VP_CP_CMD_ACTIVATE. The caller must set this key when the + /// dwCPCommand field is either VP_CP_CMD_DEACTIVATE or VP_CP_CMD_CHANGE. If the caller sets an incorrect key, the driver must + /// not change the current copy protection settings. This field is valid only for VP_COMMAND_SET. + /// + public uint dwCPKey; + + /// The DVD APS trigger bit flag. This is valid only for VP_COMMAND_SET. Currently, only bits 0 and 1 are valid. + public uint bCP_APSTriggerBits; + + /// + /// The OEM-specific copy protection data. Maximum of 256 characters. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET. + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string bOEMCopyProtection; + } + } +} \ No newline at end of file diff --git a/PInvoke/User32.Gdi/WinUser.Accelerator.cs b/PInvoke/User32.Gdi/WinUser.Accelerator.cs new file mode 100644 index 00000000..da41fb3c --- /dev/null +++ b/PInvoke/User32.Gdi/WinUser.Accelerator.cs @@ -0,0 +1,271 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// Flags used by . + [PInvokeData("winuser.h")] + [Flags] + public enum FVIRT : byte + { + /// + /// The key member specifies a virtual-key code. If this flag is not specified, key is assumed to specify a character code. + /// + FVIRTKEY = 0x01, + + /// + /// No top-level menu item is highlighted when the accelerator is used. If this flag is not specified, a top-level menu item will + /// be highlighted, if possible, when the accelerator is used. This attribute is obsolete and retained only for backward + /// compatibility with resource files designed for 16-bit Windows. + /// + FNOINVERT = 0x02, + + /// The SHIFT key must be held down when the accelerator key is pressed. + FSHIFT = 0x04, + + /// The CTRL key must be held down when the accelerator key is pressed. + FCONTROL = 0x08, + + /// The ALT key must be held down when the accelerator key is pressed. + FALT = 0x10, + } + + /// + /// Copies the specified accelerator table. This function is used to obtain the accelerator-table data that corresponds to an + /// accelerator-table handle, or to determine the size of the accelerator-table data. + /// + /// + /// Type: HACCEL + /// A handle to the accelerator table to copy. + /// + /// + /// Type: LPACCEL + /// An array of ACCEL structures that receives the accelerator-table information. + /// + /// + /// Type: int + /// The number of ACCEL structures to copy to the buffer pointed to by the lpAccelDst parameter. + /// + /// + /// Type: int + /// + /// If lpAccelDst is NULL, the return value specifies the number of accelerator-table entries in the original table. + /// Otherwise, it specifies the number of accelerator-table entries that were copied. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-copyacceleratortablea int CopyAcceleratorTableA( HACCEL + // hAccelSrc, LPACCEL lpAccelDst, int cAccelEntries ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h")] + public static extern int CopyAcceleratorTable(HACCEL hAccelSrc, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ACCEL[] lpAccelDst, int cAccelEntries); + + /// Creates an accelerator table. + /// + /// Type: LPACCEL + /// An array of ACCEL structures that describes the accelerator table. + /// + /// + /// Type: int + /// The number of ACCEL structures in the array. This must be within the range 1 to 32767 or the function will fail. + /// + /// + /// Type: HACCEL + /// + /// If the function succeeds, the return value is the handle to the created accelerator table; otherwise, it is NULL. To get + /// extended error information, call GetLastError. + /// + /// + /// + /// + /// Before an application closes, it can use the DestroyAcceleratorTable function to destroy any accelerator tables that it created + /// by using the CreateAcceleratorTable function. + /// + /// Examples + /// For an example, see Creating User Editable Accelerators. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-createacceleratortablea HACCEL CreateAcceleratorTableA( + // LPACCEL paccel, int cAccel ); + [DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h")] + public static extern SafeHACCEL CreateAcceleratorTable([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ACCEL[] paccel, int cAccel); + + /// Destroys an accelerator table. + /// + /// Type: HACCEL + /// + /// A handle to the accelerator table to be destroyed. This handle must have been created by a call to the CreateAcceleratorTable or + /// LoadAccelerators function. + /// + /// + /// + /// Type: BOOL + /// + /// If the function succeeds, the return value is nonzero. However, if the table has been loaded more than one call to + /// LoadAccelerators, the function will return a nonzero value only when DestroyAcceleratorTable has been called an equal + /// number of times. + /// + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-destroyacceleratortable BOOL DestroyAcceleratorTable( + // HACCEL hAccel ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DestroyAcceleratorTable(HACCEL hAccel); + + /// Loads the specified accelerator table. + /// + /// Type: HINSTANCE + /// A handle to the module whose executable file contains the accelerator table to be loaded. + /// + /// + /// Type: LPCTSTR + /// + /// The name of the accelerator table to be loaded. Alternatively, this parameter can specify the resource identifier of an + /// accelerator-table resource in the low-order word and zero in the high-order word. To create this value, use the MAKEINTRESOURCE macro. + /// + /// + /// + /// Type: HACCEL + /// If the function succeeds, the return value is a handle to the loaded accelerator table. + /// If the function fails, the return value is NULL. To get extended error information, call GetLastError. + /// + /// + /// If the accelerator table has not yet been loaded, the function loads it from the specified executable file. + /// Accelerator tables loaded from resources are freed automatically when the application terminates. + /// Examples + /// For an example, see Creating Accelerators for Font Attributes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-loadacceleratorsa HACCEL LoadAcceleratorsA( HINSTANCE + // hInstance, LPCSTR lpTableName ); + [DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h")] + public static extern HACCEL LoadAccelerators(HINSTANCE hInstance, string lpTableName); + + /// + /// Processes accelerator keys for menu commands. The function translates a WM_KEYDOWN or WM_SYSKEYDOWN message to a WM_COMMAND or + /// WM_SYSCOMMAND message (if there is an entry for the key in the specified accelerator table) and then sends the WM_COMMAND + /// or WM_SYSCOMMAND message directly to the specified window procedure. TranslateAccelerator does not return until the + /// window procedure has processed the message. + /// + /// + /// Type: HWND + /// A handle to the window whose messages are to be translated. + /// + /// + /// Type: HACCEL + /// + /// A handle to the accelerator table. The accelerator table must have been loaded by a call to the LoadAccelerators function or + /// created by a call to the CreateAcceleratorTable function. + /// + /// + /// + /// Type: LPMSG + /// + /// A pointer to an MSG structure that contains message information retrieved from the calling thread's message queue using the + /// GetMessage or PeekMessage function. + /// + /// + /// + /// Type: int + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// To differentiate the message that this function sends from messages sent by menus or controls, the high-order word of the wParam + /// parameter of the WM_COMMAND or WM_SYSCOMMAND message contains the value 1. + /// + /// + /// Accelerator key combinations used to select items from the window menu are translated into WM_SYSCOMMAND messages; all + /// other accelerator key combinations are translated into WM_COMMAND messages. + /// + /// + /// When TranslateAccelerator returns a nonzero value and the message is translated, the application should not use the + /// TranslateMessage function to process the message again. + /// + /// An accelerator need not correspond to a menu command. + /// + /// If the accelerator command corresponds to a menu item, the application is sent WM_INITMENU and WM_INITMENUPOPUP messages, as if + /// the user were trying to display the menu. However, these messages are not sent if any of the following conditions exist: + /// + /// + /// + /// The window is disabled. + /// + /// + /// The accelerator key combination does not correspond to an item on the window menu and the window is minimized. + /// + /// + /// A mouse capture is in effect. For information about mouse capture, see the SetCapture function. + /// + /// + /// + /// If the specified window is the active window and no window has the keyboard focus (which is generally the case if the window is + /// minimized), TranslateAccelerator translates WM_SYSKEYUP and WM_SYSKEYDOWN messages instead of WM_KEYUP and WM_KEYDOWN messages. + /// + /// + /// If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, + /// TranslateAccelerator does not send a WM_COMMAND message. However, if an accelerator keystroke occurs that does not match + /// any of the items in the window's menu or in the window menu, the function sends a WM_COMMAND message, even if the + /// window is minimized. + /// + /// Examples + /// For an example, see Creating Accelerators for Font Attributes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-translateacceleratora int TranslateAcceleratorA( HWND + // hWnd, HACCEL hAccTable, LPMSG lpMsg ); + [DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h")] + public static extern int TranslateAccelerator(HWND hWnd, HACCEL hAccTable, in MSG lpMsg); + + /// + /// Defines an accelerator key used in an accelerator table. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagaccel typedef struct tagACCEL { #if ... BYTE fVirt; + // WORD key; #if ... WORD cmd; #else WORD fVirt; #endif #else DWORD cmd; #endif } ACCEL, *LPACCEL; + [PInvokeData("winuser.h")] + [StructLayout(LayoutKind.Sequential)] + public struct ACCEL + { + /// The accelerator behavior. This member can be one or more of the following values. + public FVIRT fVirt; + + /// + /// Type: WORD + /// The accelerator key. This member can be either a virtual-key code or a character code. + /// + public ushort key; + + /// + /// The accelerator identifier. This value is placed in the low-order word of the wParam parameter of the WM_COMMAND or + /// WM_SYSCOMMAND message when the accelerator is pressed. + /// + public ushort cmd; + } + + /// Provides a for that is disposed using . + public class SafeHACCEL : SafeHANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeHACCEL(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeHACCEL() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator HACCEL(SafeHACCEL h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => DestroyAcceleratorTable(this); + } + } +} \ No newline at end of file diff --git a/PInvoke/User32.Gdi/WinUser.Caret.cs b/PInvoke/User32.Gdi/WinUser.Caret.cs new file mode 100644 index 00000000..69d48119 --- /dev/null +++ b/PInvoke/User32.Gdi/WinUser.Caret.cs @@ -0,0 +1,270 @@ +using System.Drawing; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// + /// Creates a new shape for the system caret and assigns ownership of the caret to the specified window. The caret shape can be a + /// line, a block, or a bitmap. + /// + /// + /// Type: HWND + /// A handle to the window that owns the caret. + /// + /// + /// Type: HBITMAP + /// + /// A handle to the bitmap that defines the caret shape. If this parameter is NULL, the caret is solid. If this parameter is , + /// the caret is gray. If this parameter is a bitmap handle, the caret is the specified bitmap. The bitmap handle must have been + /// created by the CreateBitmap, CreateDIBitmap, or LoadBitmap function. + /// + /// + /// If hBitmap is a bitmap handle, CreateCaret ignores the nWidth and nHeight parameters; the bitmap defines its own width and height. + /// + /// + /// + /// Type: int + /// + /// The width of the caret, in logical units. If this parameter is zero, the width is set to the system-defined window border width. + /// If hBitmap is a bitmap handle, CreateCaret ignores this parameter. + /// + /// + /// + /// Type: int + /// + /// The height of the caret, in logical units. If this parameter is zero, the height is set to the system-defined window border + /// height. If hBitmap is a bitmap handle, CreateCaret ignores this parameter. + /// + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// The nWidth and nHeight parameters specify the caret's width and height, in logical units; the exact width and height, in pixels, + /// depend on the window's mapping mode. + /// + /// + /// CreateCaret automatically destroys the previous caret shape, if any, regardless of the window that owns the caret. The + /// caret is hidden until the application calls the ShowCaret function to make the caret visible. + /// + /// + /// 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. + /// + /// DPI Virtualization + /// + /// This API does not participate in DPI virtualization. The width and height parameters are interpreted as logical sizes in terms of + /// the window in question. The calling thread is not taken into consideration. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-createcaret BOOL CreateCaret( HWND hWnd, HBITMAP hBitmap, + // int nWidth, int nHeight ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CreateCaret(HWND hWnd, HBITMAP hBitmap, int nWidth, int nHeight); + + /// Destroys the caret's current shape, frees the caret from the window, and removes the caret from the screen. + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// DestroyCaret destroys the caret only if a window in the current task owns the caret. If a window that is not in the + /// current task owns the caret, DestroyCaret does nothing and returns FALSE. + /// + /// + /// 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. + /// + /// For an example, see Destroying a Caret + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-destroycaret BOOL DestroyCaret( ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DestroyCaret(); + + /// Retrieves the time required to invert the caret's pixels. The user can set this value. + /// + /// Type: UINT + /// If the function succeeds, the return value is the blink time, in milliseconds. + /// A return value of INFINITE indicates that the caret does not blink. + /// A return value is zero indicates that the function has failed. To get extended error information, call GetLastError. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getcaretblinktime UINT GetCaretBlinkTime( ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + public static extern uint GetCaretBlinkTime(); + + /// Copies the caret's position to the specified POINT structure. + /// + /// Type: LPPOINT + /// A pointer to the POINT structure that is to receive the client coordinates of the caret. + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// The caret position is always given in the client coordinates of the window that contains the caret. + /// DPI Virtualization + /// + /// 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. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getcaretpos BOOL GetCaretPos( LPPOINT lpPoint ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetCaretPos(out Point lpPoint); + + /// + /// Removes the caret from the screen. Hiding a caret does not destroy its current shape or invalidate the insertion point. + /// + /// + /// Type: HWND + /// + /// A handle to the window that owns the caret. If this parameter is NULL, HideCaret searches the current task for the + /// window that owns the caret. + /// + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// HideCaret hides the caret only if the specified window owns the caret. If the specified window does not own the caret, + /// HideCaret does nothing and returns FALSE. + /// + /// + /// Hiding is cumulative. If your application calls HideCaret five times in a row, it must also call ShowCaret five times + /// before the caret is displayed. + /// + /// For an example, see Hiding a Caret. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-hidecaret BOOL HideCaret( HWND hWnd ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool HideCaret(HWND hWnd); + + /// + /// Sets the caret blink time to the specified number of milliseconds. The blink time is the elapsed time, in milliseconds, required + /// to invert the caret's pixels. + /// + /// + /// Type: UINT + /// The new blink time, in milliseconds. + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// The user can set the blink time using the Control Panel. Applications should respect the setting that the user has chosen. The + /// SetCaretBlinkTime function should only be used by application that allow the user to set the blink time, such as a Control + /// Panel applet. + /// + /// + /// If you change the blink time, subsequently activated applications will use the modified blink time, even if you restore the + /// previous blink time when you lose the keyboard focus or become inactive. This is due to the multithreaded environment, where + /// deactivation of your application is not synchronized with the activation of another application. This feature allows the system + /// to activate another application even if the current application is not responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setcaretblinktime BOOL SetCaretBlinkTime( UINT uMSeconds ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetCaretBlinkTime(uint uMSeconds); + + /// + /// Moves the caret to the specified coordinates. If the window that owns the caret was created with the CS_OWNDC class style, + /// then the specified coordinates are subject to the mapping mode of the device context associated with that window. + /// + /// + /// Type: int + /// The new x-coordinate of the caret. + /// + /// + /// Type: int + /// The new y-coordinate of the caret. + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// SetCaretPos moves the caret whether the caret is hidden. + /// + /// 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. A window can set the caret position only + /// if it owns the caret. + /// + /// DPI Virtualization + /// + /// This API does not participate in DPI virtualization. The provided position is interpreted as logical coordinates in terms of the + /// window associated with the caret. The calling thread is not taken into consideration. + /// + /// Examples + /// For an example, see Creating and Displaying a Caret. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setcaretpos BOOL SetCaretPos( int X, int Y ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetCaretPos(int X, int Y); + + /// + /// Makes the caret visible on the screen at the caret's current position. When the caret becomes visible, it begins flashing automatically. + /// + /// + /// Type: HWND + /// + /// A handle to the window that owns the caret. If this parameter is NULL, ShowCaret searches the current task for the + /// window that owns the caret. + /// + /// + /// + /// Type: BOOL + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + /// + /// + /// ShowCaret 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, ShowCaret does nothing and returns FALSE. + /// + /// + /// Hiding is cumulative. If your application calls HideCaret five times in a row, it must also call ShowCaret 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. + /// + /// Examples + /// For an example, see Creating and Displaying a Caret. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-showcaret BOOL ShowCaret( HWND hWnd ); + [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] + [PInvokeData("winuser.h")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ShowCaret(HWND hWnd); + } +} \ No newline at end of file diff --git a/PInvoke/User32.Gdi/WinUser.CoordSpace.cs b/PInvoke/User32.Gdi/WinUser.CoordSpace.cs new file mode 100644 index 00000000..ea39da17 --- /dev/null +++ b/PInvoke/User32.Gdi/WinUser.CoordSpace.cs @@ -0,0 +1,201 @@ +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// + /// Indicates the screen orientation preference for a desktop app process. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ne-winuser-orientation_preference typedef enum ORIENTATION_PREFERENCE + // { ORIENTATION_PREFERENCE_NONE, ORIENTATION_PREFERENCE_LANDSCAPE, ORIENTATION_PREFERENCE_PORTRAIT, + // ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED, ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED } ; + [PInvokeData("winuser.h", MSDNShortId = "7399DD9F-F993-40CC-B9C6-20673D39C069")] + [Flags] + public enum ORIENTATION_PREFERENCE + { + /// The process has no device orientation preferences. The system may choose any available setting. + ORIENTATION_PREFERENCE_NONE = 0x00, + + /// The process represents a desktop app that can be used in landscape mode. + ORIENTATION_PREFERENCE_LANDSCAPE = 0x01, + + /// The process represents a desktop app that can be used in portrait mode. + ORIENTATION_PREFERENCE_PORTRAIT = 0x02, + + /// The process represents a desktop app that can be used in flipped landscape mode. + ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = 0x04, + + /// The process represents a desktop app that can be used in flipped portrait mode. + ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = 0x08, + } + + /// The ClientToScreen function converts the client-area coordinates of a specified point to screen coordinates. + /// A handle to the window whose client area is used for the conversion. + /// + /// A pointer to a POINT structure that contains the client coordinates to be converted. The new screen coordinates are copied into + /// this structure if the function succeeds. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// The ClientToScreen function replaces the client-area coordinates in the POINT 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. + /// Examples + /// For an example, see "Drawing Lines with the Mouse" in Using Mouse Input. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-clienttoscreen BOOL ClientToScreen( HWND hWnd, LPPOINT + // lpPoint ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "3b1e2699-7f5f-444d-9072-f2ca7c8fa511")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ClientToScreen(HWND hWnd, ref Point lpPoint); + + /// Retrieves the screen auto-rotation preferences for the current process. + /// + /// Pointer to a location in memory that will receive the current orientation preference setting for the calling process. + /// + /// TRUE if the method succeeds, otherwise FALSE. + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdisplayautorotationpreferences BOOL + // GetDisplayAutoRotationPreferences( ORIENTATION_PREFERENCE *pOrientation ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "48D609CC-3E2B-4E0E-9566-FE02853DD831")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetDisplayAutoRotationPreferences(out ORIENTATION_PREFERENCE pOrientation); + + /// + /// The MapWindowPoints function converts (maps) a set of points from a coordinate space relative to one window to a coordinate space + /// relative to another window. + /// + /// + /// A handle to the window from which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are presumed to be + /// in screen coordinates. + /// + /// + /// A handle to the window to which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are converted to + /// screen coordinates. + /// + /// + /// A pointer to an array of POINT structures that contain the set of points to be converted. The points are in device units. This + /// parameter can also point to a RECT structure, in which case the cPoints parameter should be set to 2. + /// + /// The number of POINT structures in the array pointed to by the lpPoints parameter. + /// + /// If the function succeeds, the low-order word of the return value is the number of pixels added to the horizontal coordinate of + /// each source point in order to compute the horizontal coordinate of each destination point. (In addition to that, if precisely one + /// of hWndFrom and hWndTo is mirrored, then each resulting horizontal coordinate is multiplied by -1.) The high-order word is the + /// number of pixels added to the vertical coordinate of each source point in order to compute the vertical coordinate of each + /// destination point. + /// + /// If the function fails, the return value is zero. Call SetLastError prior to calling this method to differentiate an error return + /// value from a legitimate "0" return value. + /// + /// + [PInvokeData("WinUser.h", MSDNShortId = "")] + [DllImport(Lib.User32, ExactSpelling = true, SetLastError = true)] + public static extern int MapWindowPoints(HWND hWndFrom, HWND hWndTo, ref RECT lpPoints, uint cPoints = 2); + + /// + /// The MapWindowPoints function converts (maps) a set of points from a coordinate space relative to one window to a coordinate space + /// relative to another window. + /// + /// + /// A handle to the window from which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are presumed to be + /// in screen coordinates. + /// + /// + /// A handle to the window to which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are converted to + /// screen coordinates. + /// + /// + /// A pointer to an array of POINT structures that contain the set of points to be converted. The points are in device units. This + /// parameter can also point to a RECT structure, in which case the cPoints parameter should be set to 2. + /// + /// The number of POINT structures in the array pointed to by the lpPoints parameter. + /// + /// If the function succeeds, the low-order word of the return value is the number of pixels added to the horizontal coordinate of + /// each source point in order to compute the horizontal coordinate of each destination point. (In addition to that, if precisely one + /// of hWndFrom and hWndTo is mirrored, then each resulting horizontal coordinate is multiplied by -1.) The high-order word is the + /// number of pixels added to the vertical coordinate of each source point in order to compute the vertical coordinate of each + /// destination point. + /// + /// If the function fails, the return value is zero. Call SetLastError prior to calling this method to differentiate an error return + /// value from a legitimate "0" return value. + /// + /// + [PInvokeData("WinUser.h", MSDNShortId = "")] + [DllImport(Lib.User32, ExactSpelling = true, SetLastError = true)] + public static extern int MapWindowPoints(HWND hWndFrom, HWND hWndTo, ref Point lpPoints, uint cPoints = 1); + + /// + /// The MapWindowPoints function converts (maps) a set of points from a coordinate space relative to one window to a coordinate space + /// relative to another window. + /// + /// + /// A handle to the window from which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are presumed to be + /// in screen coordinates. + /// + /// + /// A handle to the window to which points are converted. If this parameter is NULL or HWND_DESKTOP, the points are converted to + /// screen coordinates. + /// + /// + /// A pointer to an array of POINT structures that contain the set of points to be converted. The points are in device units. This + /// parameter can also point to a RECT structure, in which case the cPoints parameter should be set to 2. + /// + /// The number of POINT structures in the array pointed to by the lpPoints parameter. + /// + /// If the function succeeds, the low-order word of the return value is the number of pixels added to the horizontal coordinate of + /// each source point in order to compute the horizontal coordinate of each destination point. (In addition to that, if precisely one + /// of hWndFrom and hWndTo is mirrored, then each resulting horizontal coordinate is multiplied by -1.) The high-order word is the + /// number of pixels added to the vertical coordinate of each source point in order to compute the vertical coordinate of each + /// destination point. + /// + /// If the function fails, the return value is zero. Call SetLastError prior to calling this method to differentiate an error return + /// value from a legitimate "0" return value. + /// + /// + [PInvokeData("WinUser.h", MSDNShortId = "")] + [DllImport(Lib.User32, ExactSpelling = true, SetLastError = true)] + public static extern int MapWindowPoints(HWND hWndFrom, HWND hWndTo, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] Point[] lpPoints, [MarshalAs(UnmanagedType.U4)] int cPoints); + + /// The ScreenToClient function converts the screen coordinates of a specified point on the screen to client-area coordinates. + /// A handle to the window whose client area will be used for the conversion. + /// A pointer to a POINT structure that specifies the screen coordinates to be converted. + /// + /// If the function succeeds, the return value is true. If the function fails, the return value is false. To get extended error + /// information, call GetLastError. + /// + [DllImport(Lib.User32, ExactSpelling = true, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + [System.Security.SecurityCritical] + public static extern bool ScreenToClient(HWND hWnd, [In, Out] ref Point lpPoint); + + /// Sets the orientation preferences of the display. + /// The orientation. + /// + /// Type: BOOL + /// If this function set the orientation preferences, the return value is nonzero. + /// If the orientation preferences weren't set, the return value is zero. + /// + /// + /// An app can remove the orientation preferences of the display after it sets them by passing ORIENTATION_PREFERENCE_NONE to + /// SetDisplayAutoRotationPreferences. An app can change the orientation preferences of the display by passing a different + /// combination of ORIENTATION_PREFERENCE-typed values to SetDisplayAutoRotationPreferences. + /// + // https://docs.microsoft.com/en-us/previous-versions/dn376361(v=vs.85) BOOL WINAPI SetDisplayAutoRotationPreferences( _In_ + // ORIENTATION_PREFERENCE orientation ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("Winuser.h", MSDNShortId = "")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetDisplayAutoRotationPreferences([In] ORIENTATION_PREFERENCE orientation); + } +} \ No newline at end of file diff --git a/PInvoke/User32.Gdi/WinUser.Paint.cs b/PInvoke/User32.Gdi/WinUser.Paint.cs new file mode 100644 index 00000000..32e41c89 --- /dev/null +++ b/PInvoke/User32.Gdi/WinUser.Paint.cs @@ -0,0 +1,1867 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// + /// The DrawStateProc function is an application-defined callback function that renders a complex image for the DrawState + /// function. The DRAWSTATEPROC type defines a pointer to this callback function. DrawStateProc is a placeholder for + /// the application-defined function name. + /// + /// + /// A handle to the device context to draw in. The device context is a memory device context with a bitmap selected, the dimensions + /// of which are at least as great as those specified by the cx and cy parameters. + /// + /// Specifies information about the image, which the application passed to DrawState. + /// Specifies information about the image, which the application passed to DrawState. + /// The image width, in device units, as specified by the call to DrawState. + /// The image height, in device units, as specified by the call to DrawState. + /// + /// If the function succeeds, the return value is TRUE. + /// If the function fails, the return value is FALSE. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nc-winuser-drawstateproc DRAWSTATEPROC Drawstateproc; BOOL + // Drawstateproc( HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy ) {...} + [PInvokeData("winuser.h", MSDNShortId = "a95a4020-e433-4b2c-96e7-f272e28e5a43")] + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DrawStateProc(HDC hdc, IntPtr lData, IntPtr wData, int cx, int cy); + + /// + /// The OutputProc function is an application-defined callback function used with the GrayString function. It is used to draw + /// a string. The GRAYSTRINGPROC type defines a pointer to this callback function. OutputProc is a placeholder for the + /// application-defined or library-defined function name. + /// + /// + /// A handle to a device context with a bitmap of at least the width and height specified by the nWidth and nHeight parameters passed + /// to GrayString. + /// + /// A pointer to the string to be drawn. + /// The length, in characters, of the string. + /// + /// If it succeeds, the callback function should return TRUE. + /// If the function fails, the return value is FALSE. + /// + /// The callback function must draw an image relative to the coordinates (0,0). + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nc-winuser-graystringproc GRAYSTRINGPROC Graystringproc; BOOL + // Graystringproc( HDC Arg1, LPARAM Arg2, int Arg3 ) {...} + [PInvokeData("winuser.h", MSDNShortId = "4d9145d2-5be4-4da3-9d03-01ebd74e0d06")] + [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool OutputProc(HDC hdc, string lpData, int cchData); + + /// Flags used by the method. + [PInvokeData("WinUser.h")] + [Flags] + public enum BorderFlags : uint + { + /// Left side of border rectangle. + BF_LEFT = 0x0001, + + /// Top of border rectangle. + BF_TOP = 0x0002, + + /// Right side of border rectangle. + BF_RIGHT = 0x0004, + + /// Bottom of border rectangle. + BF_BOTTOM = 0x0008, + + /// Top and left side of border rectangle. + BF_TOPLEFT = BF_TOP | BF_LEFT, + + /// Top and right side of border rectangle. + BF_TOPRIGHT = BF_TOP | BF_RIGHT, + + /// Bottom and left side of border rectangle. + BF_BOTTOMLEFT = BF_BOTTOM | BF_LEFT, + + /// Bottom and right side of border rectangle. + BF_BOTTOMRIGHT = BF_BOTTOM | BF_RIGHT, + + /// Entire border rectangle. + BF_RECT = BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM, + + /// Diagonal border. + BF_DIAGONAL = 0x0010, + + /// Diagonal border. The end point is the top-right corner of the rectangle; the origin is lower-left corner. + BF_DIAGONAL_ENDTOPRIGHT = BF_DIAGONAL | BF_TOP | BF_RIGHT, + + /// Diagonal border. The end point is the top-left corner of the rectangle; the origin is lower-right corner. + BF_DIAGONAL_ENDTOPLEFT = BF_DIAGONAL | BF_TOP | BF_LEFT, + + /// Diagonal border. The end point is the lower-left corner of the rectangle; the origin is top-right corner. + BF_DIAGONAL_ENDBOTTOMLEFT = BF_DIAGONAL | BF_BOTTOM | BF_LEFT, + + /// Diagonal border. The end point is the lower-right corner of the rectangle; the origin is top-left corner. + BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL | BF_BOTTOM | BF_RIGHT, + + /// Interior of rectangle to be filled. + BF_MIDDLE = 0x0800, + + /// Soft buttons instead of tiles. + BF_SOFT = 0x1000, + + /// + /// The rectangle pointed to by the pDestRect parameter is shrunk to exclude the edges that were drawn; otherwise the rectangle + /// does not change. + /// + BF_ADJUST = 0x2000, + + /// Flat border. + BF_FLAT = 0x4000, + + /// One-dimensional border. + BF_MONO = 0x8000, + } + + /// Styles used by the method. + [PInvokeData("WinUser.h")] + [Flags] + public enum BorderStyles3D : uint + { + /// Raised outer edge + BDR_RAISEDOUTER = 0x0001, + + /// Sunken outer edge + BDR_SUNKENOUTER = 0x0002, + + /// Raised inner edge + BDR_RAISEDINNER = 0x0004, + + /// Sunken inner edge + BDR_SUNKENINNER = 0x0008, + + /// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER + BDR_OUTER = BDR_RAISEDOUTER | BDR_SUNKENOUTER, + + /// Combination of BDR_RAISEDINNER and BDR_SUNKENINNER + BDR_INNER = BDR_RAISEDINNER | BDR_SUNKENINNER, + + /// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER + BDR_RAISED = BDR_RAISEDOUTER | BDR_RAISEDINNER, + + /// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER + BDR_SUNKEN = BDR_SUNKENOUTER | BDR_SUNKENINNER, + + /// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER + EDGE_RAISED = BDR_RAISEDOUTER | BDR_RAISEDINNER, + + /// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER + EDGE_SUNKEN = BDR_SUNKENOUTER | BDR_SUNKENINNER, + + /// Combination of BDR_SUNKENOUTER and BDR_RAISEDINNER + EDGE_ETCHED = BDR_SUNKENOUTER | BDR_RAISEDINNER, + + /// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER + EDGE_BUMP = BDR_RAISEDOUTER | BDR_SUNKENINNER, + } + + /// Flags used by . + [PInvokeData("winuser.h", MSDNShortId = "9348e29f-ce56-4664-8862-f5810c797622")] + [Flags] + public enum DrawCaptionFlags + { + /// The function uses the colors that denote an active caption. + DC_ACTIVE = 0x0001, + + /// The function draws a small caption, using the current small caption font. + DC_SMALLCAP = 0x0002, + + /// The function draws the icon when drawing the caption text. + DC_ICON = 0x0004, + + /// The function draws the caption text when drawing the caption. + DC_TEXT = 0x0008, + + /// The function draws the caption as a button. + DC_INBUTTON = 0x0010, + + /// + /// When this flag is set, the function uses COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or + /// COLOR_GRADIENTINACTIVECAPTION for the title-bar color. + /// If this flag is not set, the function uses COLOR_ACTIVECAPTION or COLOR_INACTIVECAPTION for both colors. + /// + DC_GRADIENT = 0x0020, + + /// If set, the function draws the buttons in the caption bar (to minimize, restore, or close an application). + DC_BUTTONS = 0x1000, + } + + /// Flags used by . + [PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")] + [Flags] + public enum DrawStateFlags + { + /// + /// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter. + /// + DST_COMPLEX = 0x0000, + + /// + /// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is + /// zero, the string must be null-terminated. + /// + DST_TEXT = 0x0001, + + /// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character + /// as a directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData + /// parameter specifies the length. If wData is zero, the string must be null-terminated. + DST_PREFIXTEXT = 0x0002, + + /// The image is an icon. The lData parameter is the icon handle. + DST_ICON = 0x0003, + + /// + /// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an + /// existing device context. + /// + DST_BITMAP = 0x0004, + + /// Draws the image without any modification. + DSS_NORMAL = 0x0000, + + /// Dithers the image. + DSS_UNION = 0x0010, + + /// Embosses the image. + DSS_DISABLED = 0x0020, + + /// Draws the image using the brush specified by the hbr parameter. + DSS_MONO = 0x0080, + + /// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This + /// must be used with DST_PREFIXTEXT. + DSS_HIDEPREFIX = 0x0200, + + /// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the + /// string is drawn. This must be used with DST_PREFIXTEXT. + DSS_PREFIXONLY = 0x0400, + + /// Aligns the text to the right. + DSS_RIGHT = 0x8000, + } + + /// State of the control to draw with . + [PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")] + [Flags] + public enum FrameControlState + { + /// Close button + DFCS_CAPTIONCLOSE = 0x0000, + + /// Minimize button + DFCS_CAPTIONMIN = 0x0001, + + /// Maximize button + DFCS_CAPTIONMAX = 0x0002, + + /// Restore button + DFCS_CAPTIONRESTORE = 0x0003, + + /// Help button + DFCS_CAPTIONHELP = 0x0004, + + /// Submenu arrow + DFCS_MENUARROW = 0x0000, + + /// Check mark + DFCS_MENUCHECK = 0x0001, + + /// Bullet + DFCS_MENUBULLET = 0x0002, + + /// + /// Submenu arrow pointing left. This is used for the right-to-left cascading menus used with right-to-left languages such as + /// Arabic or Hebrew. + /// + DFCS_MENUARROWRIGHT = 0x0004, + + /// Up arrow of scroll bar + DFCS_SCROLLUP = 0x0000, + + /// Down arrow of scroll bar + DFCS_SCROLLDOWN = 0x0001, + + /// Left arrow of scroll bar + DFCS_SCROLLLEFT = 0x0002, + + /// Right arrow of scroll bar + DFCS_SCROLLRIGHT = 0x0003, + + /// Combo box scroll bar + DFCS_SCROLLCOMBOBOX = 0x0005, + + /// Size grip in lower-right corner of window + DFCS_SCROLLSIZEGRIP = 0x0008, + + /// Size grip in lower-left corner of window. This is used with right-to-left languages such as Arabic or Hebrew. + DFCS_SCROLLSIZEGRIPRIGHT = 0x0010, + + /// Check box + DFCS_BUTTONCHECK = 0x0000, + + /// Image for radio button (nonsquare needs image) + DFCS_BUTTONRADIOIMAGE = 0x0001, + + /// Mask for radio button (nonsquare needs mask) + DFCS_BUTTONRADIOMASK = 0x0002, + + /// Radio button + DFCS_BUTTONRADIO = 0x0004, + + /// Three-state button + DFCS_BUTTON3STATE = 0x0008, + + /// Push button + DFCS_BUTTONPUSH = 0x0010, + + /// Button is inactive (grayed). + DFCS_INACTIVE = 0x0100, + + /// Button is pushed. + DFCS_PUSHED = 0x0200, + + /// Button is checked. + DFCS_CHECKED = 0x0400, + + /// The background remains untouched. This flag can only be combined with DFCS_MENUARROWUP or DFCS_MENUARROWDOWN. + DFCS_TRANSPARENT = 0x0800, + + /// Button is hot-tracked. + DFCS_HOT = 0x1000, + + /// Bounding rectangle is adjusted to exclude the surrounding edge of the push button. + DFCS_ADJUSTRECT = 0x2000, + + /// Button has a flat border. + DFCS_FLAT = 0x4000, + + /// Button has a monochrome border. + DFCS_MONO = 0x8000, + } + + /// Type of control to draw with . + [PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")] + public enum FrameControlType + { + /// Title bar. + DFC_CAPTION = 1, + + /// Menu bar. + DFC_MENU = 2, + + /// Scroll bar. + DFC_SCROLL = 3, + + /// Standard button. + DFC_BUTTON = 4, + + /// Popup menu item. + DFC_POPUPMENU = 5, + } + + /// Flags used by . + [PInvokeData("winuser.h", MSDNShortId = "54a9234a-0056-4cfe-9158-86635dc31bc6")] + public enum IDANI + { + /// + IDANI_OPEN = 1, + + /// + /// The window caption will animate from the position specified by lprcFrom to the position specified by lprcTo. The effect is + /// similar to minimizing or maximizing a window. + /// + IDANI_CAPTION = 3 + } + + /// Flags used to invalidate or validate a window, control repainting, and control which windows are affected by RedrawWindow. + [PInvokeData("winuser.h", MSDNShortId = "c6cb7f74-237e-4d3e-a852-894da36e990c")] + [Flags] + public enum RedrawWindowFlags + { + /// Invalidates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is invalidated. + RDW_INVALIDATE = 0x0001, + + /// Causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid. + RDW_INTERNALPAINT = 0x0002, + + /// + /// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. The RDW_INVALIDATE flag must also be + /// specified; otherwise, RDW_ERASE has no effect. + /// + RDW_ERASE = 0x0004, + + /// + /// Validates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is validated. This flag + /// does not affect internal WM_PAINT messages. + /// + RDW_VALIDATE = 0x0008, + + /// + /// Suppresses any pending internal WM_PAINT messages. This flag does not affect WM_PAINT messages resulting from a non-NULL + /// update area. + /// + RDW_NOINTERNALPAINT = 0x0010, + + /// Suppresses any pending WM_ERASEBKGND messages. + RDW_NOERASE = 0x0020, + + /// Excludes child windows, if any, from the repainting operation. + RDW_NOCHILDREN = 0x0040, + + /// Includes child windows, if any, in the repainting operation. + RDW_ALLCHILDREN = 0x0080, + + /// + /// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT, + /// WM_ERASEBKGND, and WM_PAINT messages, if necessary, before the function returns. + /// + RDW_UPDATENOW = 0x0100, + + /// + /// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT and + /// WM_ERASEBKGND messages, if necessary, before the function returns. WM_PAINT messages are received at the ordinary time. + /// + RDW_ERASENOW = 0x0200, + + /// + /// Causes any part of the nonclient area of the window that intersects the update region to receive a WM_NCPAINT message. The + /// RDW_INVALIDATE flag must also be specified; otherwise, RDW_FRAME has no effect. The WM_NCPAINT message is typically not sent + /// during the execution of RedrawWindow unless either RDW_UPDATENOW or RDW_ERASENOW is specified. + /// + RDW_FRAME = 0x0400, + + /// + /// Suppresses any pending WM_NCPAINT messages. This flag must be used with RDW_VALIDATE and is typically used with + /// RDW_NOCHILDREN. RDW_NOFRAME should be used with care, as it could cause parts of a window to be painted improperly. + /// + RDW_NOFRAME = 0x0800, + } + + /// + /// The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information + /// about the painting. + /// + /// Handle to the window to be repainted. + /// Pointer to the PAINTSTRUCT structure that will receive painting information. + /// + /// If the function succeeds, the return value is the handle to a display device context for the specified window. + /// If the function fails, the return value is NULL, indicating that no display device context is available. + /// + /// + /// + /// The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the + /// update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, + /// creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, + /// BeginPaint sends a WM_ERASEBKGND message to the window. + /// + /// + /// An application should not call BeginPaint except in response to a WM_PAINT message. Each call to BeginPaint + /// must have a corresponding call to the EndPaint function. + /// + /// If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased. + /// + /// If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region + /// before returning. + /// + /// DPI Virtualization + /// This API does not participate in DPI virtualization. The output returned is always in terms of physical pixels. + /// Examples + /// For an example, see Drawing in the Client Area. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-beginpaint HDC BeginPaint( HWND hWnd, LPPAINTSTRUCT + // lpPaint ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "513341d7-bed8-469c-a067-ee71dc8860f9")] + public static extern HDC BeginPaint(HWND hWnd, out PAINTSTRUCT lpPaint); + + /// Animates the caption of a window to indicate the opening of an icon or the minimizing or maximizing of a window. + /// + /// A handle to the window whose caption should be animated on the screen. The animation will be clipped to the parent of this window. + /// + /// + /// The type of animation. This must be IDANI_CAPTION. With the IDANI_CAPTION animation type, the window caption will animate from + /// the position specified by lprcFrom to the position specified by lprcTo. The effect is similar to minimizing or maximizing a window. + /// + /// + /// A pointer to a RECT structure specifying the location and size of the icon or minimized window. Coordinates are relative to the + /// clipping window hwnd. + /// + /// + /// A pointer to a RECT structure specifying the location and size of the restored window. Coordinates are relative to the clipping + /// window hwnd. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawanimatedrects BOOL DrawAnimatedRects( HWND hwnd, int + // idAni, const RECT *lprcFrom, const RECT *lprcTo ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "54a9234a-0056-4cfe-9158-86635dc31bc6")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawAnimatedRects(HWND hwnd, IDANI idAni, in RECT lprcFrom, in RECT lprcTo); + + /// The DrawCaption function draws a window caption. + /// A handle to a window that supplies text and an icon for the window caption. + /// A handle to a device context. The function draws the window caption into this device context. + /// + /// A pointer to a RECT structure that specifies the bounding rectangle for the window caption in logical coordinates. + /// + /// + /// The drawing options. This parameter can be zero or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// DC_ACTIVE + /// The function uses the colors that denote an active caption. + /// + /// + /// DC_BUTTONS + /// If set, the function draws the buttons in the caption bar (to minimize, restore, or close an application). + /// + /// + /// DC_GRADIENT + /// + /// When this flag is set, the function uses COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or + /// COLOR_GRADIENTINACTIVECAPTION for the title-bar color. If this flag is not set, the function uses COLOR_ACTIVECAPTION or + /// COLOR_INACTIVECAPTION for both colors. + /// + /// + /// + /// DC_ICON + /// The function draws the icon when drawing the caption text. + /// + /// + /// DC_INBUTTON + /// The function draws the caption as a button. + /// + /// + /// DC_SMALLCAP + /// The function draws a small caption, using the current small caption font. + /// + /// + /// DC_TEXT + /// The function draws the caption text when drawing the caption. + /// + /// + /// If DC_SMALLCAP is specified, the function draws a normal window caption. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawcaption BOOL DrawCaption( HWND hwnd, HDC hdc, const + // RECT *lprect, UINT flags ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "9348e29f-ce56-4664-8862-f5810c797622")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawCaption(HWND hwnd, HDC hdc, in RECT lprect, DrawCaptionFlags flags); + + /// The DrawEdge function draws one or more edges of rectangle. + /// A handle to the device context. + /// A pointer to a RECT structure that contains the logical coordinates of the rectangle. + /// + /// + /// 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. + /// + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BDR_RAISEDINNER + /// Raised inner edge. + /// + /// + /// BDR_SUNKENINNER + /// Sunken inner edge. + /// + /// + /// + /// The outer-border flags are as follows. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BDR_RAISEDOUTER + /// Raised outer edge. + /// + /// + /// BDR_SUNKENOUTER + /// Sunken outer edge. + /// + /// + /// + /// Alternatively, the edge parameter can specify one of the following flags. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// EDGE_BUMP + /// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER. + /// + /// + /// EDGE_ETCHED + /// Combination of BDR_SUNKENOUTER and BDR_RAISEDINNER. + /// + /// + /// EDGE_RAISED + /// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER. + /// + /// + /// EDGE_SUNKEN + /// Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER. + /// + /// + /// + /// + /// + /// The type of border. This parameter can be a combination of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BF_ADJUST + /// + /// If this flag is passed, shrink the rectangle pointed to by the qrc parameter to exclude the edges that were drawn.If this flag is + /// not passed, then do not change the rectangle pointed to by the qrc parameter. + /// + /// + /// + /// BF_BOTTOM + /// Bottom of border rectangle. + /// + /// + /// BF_BOTTOMLEFT + /// Bottom and left side of border rectangle. + /// + /// + /// BF_BOTTOMRIGHT + /// Bottom and right side of border rectangle. + /// + /// + /// BF_DIAGONAL + /// Diagonal border. + /// + /// + /// BF_DIAGONAL_ENDBOTTOMLEFT + /// Diagonal border. The end point is the lower-left corner of the rectangle; the origin is top-right corner. + /// + /// + /// BF_DIAGONAL_ENDBOTTOMRIGHT + /// Diagonal border. The end point is the lower-right corner of the rectangle; the origin is top-left corner. + /// + /// + /// BF_DIAGONAL_ENDTOPLEFT + /// Diagonal border. The end point is the top-left corner of the rectangle; the origin is lower-right corner. + /// + /// + /// BF_DIAGONAL_ENDTOPRIGHT + /// Diagonal border. The end point is the top-right corner of the rectangle; the origin is lower-left corner. + /// + /// + /// BF_FLAT + /// Flat border. + /// + /// + /// BF_LEFT + /// Left side of border rectangle. + /// + /// + /// BF_MIDDLE + /// Interior of rectangle to be filled. + /// + /// + /// BF_MONO + /// One-dimensional border. + /// + /// + /// BF_RECT + /// Entire border rectangle. + /// + /// + /// BF_RIGHT + /// Right side of border rectangle. + /// + /// + /// BF_SOFT + /// Soft buttons instead of tiles. + /// + /// + /// BF_TOP + /// Top of border rectangle. + /// + /// + /// BF_TOPLEFT + /// Top and left side of border rectangle. + /// + /// + /// BF_TOPRIGHT + /// Top and right side of border rectangle. + /// + /// + /// + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // BOOL DrawEdge( _In_ HDC hdc, _Inout_ LPRECT qrc, _In_ UINT edge, _In_ UINT grfFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/dd162477(v=vs.85).aspx + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("Winuser.h", MSDNShortId = "dd162477")] + public static extern bool DrawEdge(HDC hdc, ref RECT qrc, BorderStyles3D edge, BorderFlags grfFlags); + + /// The DrawFocusRect function draws a rectangle in the style used to indicate that the rectangle has the focus. + /// A handle to the device context. + /// A pointer to a RECT structure that specifies the logical coordinates of the rectangle. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// DrawFocusRect works only in MM_TEXT mode. + /// + /// Because DrawFocusRect is an XOR function, calling it a second time with the same rectangle removes the rectangle from the screen. + /// + /// + /// This function draws a rectangle that cannot be scrolled. To scroll an area containing a rectangle drawn by this function, call + /// DrawFocusRect to remove the rectangle from the screen, scroll the area, and then call DrawFocusRect again to draw + /// the rectangle in the new position. + /// + /// + /// Windows XP: The focus rectangle can now be thicker than 1 pixel, so it is more visible for high-resolution, high-density + /// displays and accessibility needs. This is handled by the SPI_SETFOCUSBORDERWIDTH and SPI_SETFOCUSBORDERHEIGHT in SystemParametersInfo. + /// + /// Examples + /// For an example, see "Creating an Owner-Drawn List Box" in Using List Boxes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawfocusrect BOOL DrawFocusRect( HDC hDC, const RECT + // *lprc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "a910d04f-fe4d-4fc9-a518-abac864da6f3")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawFocusRect(HDC hDC, in RECT lprc); + + /// The DrawFrameControl function draws a frame control of the specified type and style. + /// Handle to the device context of the window in which to draw the control. + /// + /// Long pointer to a RECT structure that contains the logical coordinates of the bounding rectangle for frame control. + /// + /// Specifies the type of frame control to draw. + /// Specifies the initial state of the frame control. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// If uType is either DFC_MENU or DFC_BUTTON and uState 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 hbmMask parameter to the MaskBlt function, or it can use the + /// device context as a parameter to the BitBlt function using ROPs such as SRCAND and SRCINVERT. + /// + /// DPI Virtualization + /// + /// 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. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawframecontrol BOOL DrawFrameControl( HDC , LPRECT , + // UINT , UINT ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "3102007e-e9f7-46d8-ae10-cf156d2131f6")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawFrameControl(HDC hdc, in RECT lprc, FrameControlType uType, FrameControlState uState); + + /// + /// The DrawState function displays an image and applies a visual effect to indicate a state, such as a disabled or default state. + /// + /// A handle to the device context to draw in. + /// + /// A handle to the brush used to draw the image, if the state specified by the fuFlags parameter is DSS_MONO. This parameter is + /// ignored for other states. + /// + /// + /// A pointer to an application-defined callback function used to render the image. This parameter is required if the image type in + /// fuFlags is DST_COMPLEX. It is optional and can be NULL if the image type is DST_TEXT. For all other image types, this + /// parameter is ignored. For more information about the callback function, see the DrawStateProc function. + /// + /// Information about the image. The meaning of this parameter depends on the image type. + /// + /// Information about the image. The meaning of this parameter depends on the image type. It is, however, zero extended for use with + /// the DrawStateProc function. + /// + /// The horizontal location, in device units, at which to draw the image. + /// The vertical location, in device units, at which to draw the image. + /// + /// The width of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero + /// to calculate the width of the image. + /// + /// + /// The height of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero + /// to calculate the height of the image. + /// + /// + /// The image type and state. This parameter can be one of the following type values. + /// + /// + /// Value (type) + /// Meaning + /// + /// + /// DST_BITMAP + /// + /// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an existing + /// device context. + /// + /// + /// + /// DST_COMPLEX + /// + /// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter. + /// + /// + /// + /// DST_ICON + /// The image is an icon. The lData parameter is the icon handle. + /// + /// + /// DST_PREFIXTEXT + /// + /// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character as a + /// directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData parameter + /// specifies the length. If wData is zero, the string must be null-terminated. + /// + /// + /// + /// DST_TEXT + /// + /// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is + /// zero, the string must be null-terminated. + /// + /// + /// + /// This parameter can also be one of the following state values. + /// + /// + /// Value (state) + /// Meaning + /// + /// + /// DSS_DISABLED + /// Embosses the image. + /// + /// + /// DSS_HIDEPREFIX + /// + /// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This must be + /// used with DST_PREFIXTEXT. + /// + /// + /// + /// DSS_MONO + /// Draws the image using the brush specified by the hbr parameter. + /// + /// + /// DSS_NORMAL + /// Draws the image without any modification. + /// + /// + /// DSS_PREFIXONLY + /// + /// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the string is + /// drawn. This must be used with DST_PREFIXTEXT. + /// + /// + /// + /// DSS_RIGHT + /// Aligns the text to the right. + /// + /// + /// DSS_UNION + /// Dithers the image. + /// + /// + /// For all states except DSS_NORMAL, the image is converted to monochrome before the visual effect is applied. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawstatea BOOL DrawStateA( HDC hdc, HBRUSH hbrFore, + // DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, int x, int y, int cx, int cy, UINT uFlags ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, IntPtr lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags); + + /// + /// The DrawState function displays an image and applies a visual effect to indicate a state, such as a disabled or default state. + /// + /// A handle to the device context to draw in. + /// + /// A handle to the brush used to draw the image, if the state specified by the fuFlags parameter is DSS_MONO. This parameter is + /// ignored for other states. + /// + /// + /// A pointer to an application-defined callback function used to render the image. This parameter is required if the image type in + /// fuFlags is DST_COMPLEX. It is optional and can be NULL if the image type is DST_TEXT. For all other image types, this + /// parameter is ignored. For more information about the callback function, see the DrawStateProc function. + /// + /// Information about the image. The meaning of this parameter depends on the image type. + /// + /// Information about the image. The meaning of this parameter depends on the image type. It is, however, zero extended for use with + /// the DrawStateProc function. + /// + /// The horizontal location, in device units, at which to draw the image. + /// The vertical location, in device units, at which to draw the image. + /// + /// The width of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero + /// to calculate the width of the image. + /// + /// + /// The height of the image, in device units. This parameter is required if the image type is DST_COMPLEX. Otherwise, it can be zero + /// to calculate the height of the image. + /// + /// + /// The image type and state. This parameter can be one of the following type values. + /// + /// + /// Value (type) + /// Meaning + /// + /// + /// DST_BITMAP + /// + /// The image is a bitmap. The lData parameter is the bitmap handle. Note that the bitmap cannot already be selected into an existing + /// device context. + /// + /// + /// + /// DST_COMPLEX + /// + /// The image is application defined. To render the image, DrawState calls the callback function specified by the lpOutputFunc parameter. + /// + /// + /// + /// DST_ICON + /// The image is an icon. The lData parameter is the icon handle. + /// + /// + /// DST_PREFIXTEXT + /// + /// The image is text that may contain an accelerator mnemonic. DrawState interprets the ampersand (&) prefix character as a + /// directive to underscore the character that follows. The lData parameter is a pointer to the string, and the wData parameter + /// specifies the length. If wData is zero, the string must be null-terminated. + /// + /// + /// + /// DST_TEXT + /// + /// The image is text. The lData parameter is a pointer to the string, and the wData parameter specifies the length. If wData is + /// zero, the string must be null-terminated. + /// + /// + /// + /// This parameter can also be one of the following state values. + /// + /// + /// Value (state) + /// Meaning + /// + /// + /// DSS_DISABLED + /// Embosses the image. + /// + /// + /// DSS_HIDEPREFIX + /// + /// Ignores the ampersand (&) prefix character in the text, thus the letter that follows will not be underlined. This must be + /// used with DST_PREFIXTEXT. + /// + /// + /// + /// DSS_MONO + /// Draws the image using the brush specified by the hbr parameter. + /// + /// + /// DSS_NORMAL + /// Draws the image without any modification. + /// + /// + /// DSS_PREFIXONLY + /// + /// Draws only the underline at the position of the letter after the ampersand (&) prefix character. No text in the string is + /// drawn. This must be used with DST_PREFIXTEXT. + /// + /// + /// + /// DSS_RIGHT + /// Aligns the text to the right. + /// + /// + /// DSS_UNION + /// Dithers the image. + /// + /// + /// For all states except DSS_NORMAL, the image is converted to monochrome before the visual effect is applied. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-drawstatea BOOL DrawStateA( HDC hdc, HBRUSH hbrFore, + // DRAWSTATEPROC qfnCallBack, LPARAM lData, WPARAM wData, int x, int y, int cx, int cy, UINT uFlags ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, string lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags); + + /// + /// The EndPaint function marks the end of painting in the specified window. This function is required for each call to the + /// BeginPaint function, but only after painting is complete. + /// + /// Handle to the window that has been repainted. + /// Pointer to a PAINTSTRUCT structure that contains the painting information retrieved by BeginPaint. + /// The return value is always nonzero. + /// + /// If the caret was hidden by BeginPaint, EndPaint restores the caret to the screen. + /// EndPaint releases the display device context that BeginPaint retrieved. + /// Examples + /// For an example, see Drawing in the Client Area. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-endpaint BOOL EndPaint( HWND hWnd, const PAINTSTRUCT + // *lpPaint ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "b07cfed9-21c4-4459-855a-eaf4d1d34ab8")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EndPaint(HWND hWnd, in PAINTSTRUCT lpPaint); + + /// + /// The ExcludeUpdateRgn function prevents drawing within invalid areas of a window by excluding an updated region in the + /// window from a clipping region. + /// + /// Handle to the device context associated with the clipping region. + /// Handle to the window to update. + /// + /// The return value specifies the complexity of the excluded region; it can be any one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// COMPLEXREGION + /// Region consists of more than one rectangle. + /// + /// + /// ERROR + /// An error occurred. + /// + /// + /// NULLREGION + /// Region is empty. + /// + /// + /// SIMPLEREGION + /// Region is a single rectangle. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-excludeupdatergn int ExcludeUpdateRgn( HDC hDC, HWND hWnd ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "408fda82-30c3-4eb4-be42-3085c71ba99e")] + public static extern Gdi32.RegionFlags ExcludeUpdateRgn(HDC hDC, HWND hWnd); + + /// + /// 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. + /// + /// A handle to the device context. + /// A pointer to a RECT structure that contains the logical coordinates of the rectangle to be filled. + /// A handle to the brush used to fill the rectangle. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// The brush identified by the hbr 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: CreateHatchBrush, CreatePatternBrush, or + /// CreateSolidBrush. Additionally, you may retrieve a handle to one of the stock brushes by using the GetStockObject function. If + /// specifying a color value for the hbr parameter, it must be one of the standard system colors (the value 1 must be added to the + /// chosen color). For example: + /// + /// For a list of all the standard system colors, see GetSysColor. + /// + /// When filling the specified rectangle, FillRect does not include the rectangle's right and bottom sides. GDI fills a + /// rectangle up to, but not including, the right column and bottom row, regardless of the current mapping mode. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-fillrect + // int FillRect( HDC hDC, const RECT *lprc, HBRUSH hbr ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "98ab34da-ea07-4446-a62e-509c849d95f9")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool FillRect(HDC hDC, in RECT lprc, HBRUSH hbr); + + /// + /// The FrameRect function draws a border around the specified rectangle by using the specified brush. The width and height of the border are always one logical unit. + /// + /// A handle to the device context in which the border is drawn. + /// A pointer to a RECT structure that contains the logical coordinates of the upper-left and lower-right corners of the rectangle. + /// A handle to the brush used to draw the border. + /// + /// If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. + /// + /// + /// The brush identified by the hbr parameter must have been created by using the CreateHatchBrush, CreatePatternBrush, or CreateSolidBrush function, or retrieved by using the GetStockObject function.If the bottom member of the RECT structure is less than the top member, or if the right member is less than the left member, the function does not draw the rectangle. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-framerect + // int FrameRect( HDC hDC, const RECT *lprc, HBRUSH hbr ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "a1083cb5-5e6c-4134-badf-9fc5142d1453")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool FrameRect(HDC hDC, in RECT lprc, HBRUSH hbr); + + /// + /// The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely encloses the update region + /// of the specified window. GetUpdateRect retrieves the rectangle in logical coordinates. If there is no update region, + /// GetUpdateRect retrieves an empty rectangle (sets all coordinates to zero). + /// + /// Handle to the window whose update region is to be retrieved. + /// + /// Pointer to the RECT structure that receives the coordinates, in device units, of the enclosing rectangle. + /// + /// An application can set this parameter to NULL to determine whether an update region exists for the window. If this + /// parameter is NULL, GetUpdateRect returns nonzero if an update region exists, and zero if one does not. This + /// provides a simple and efficient means of determining whether a WM_PAINT message resulted from an invalid area. + /// + /// + /// + /// Specifies whether the background in the update region is to be erased. If this parameter is TRUE and the update region is + /// not empty, GetUpdateRect sends a WM_ERASEBKGND message to the specified window to erase the background. + /// + /// + /// If the update region is not empty, the return value is nonzero. + /// If there is no update region, the return value is zero. + /// + /// + /// The update rectangle retrieved by the BeginPaint function is identical to that retrieved by GetUpdateRect. + /// + /// BeginPaint automatically validates the update region, so any call to GetUpdateRect made immediately after the call to + /// BeginPaint retrieves an empty update region. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getupdaterect BOOL GetUpdateRect( HWND hWnd, LPRECT + // lpRect, BOOL bErase ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "e54483a1-8738-4b22-a24e-c0b31f6ca9d6")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetUpdateRect(HWND hWnd, PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase); + + /// + /// 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). + /// + /// Handle to the window with an update region that is to be retrieved. + /// Handle to the region to receive the update region. + /// + /// Specifies whether the window background should be erased and whether nonclient areas of child windows should be drawn. If this + /// parameter is FALSE, no drawing is done. + /// + /// + /// The return value indicates the complexity of the resulting region; it can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// COMPLEXREGION + /// Region consists of more than one rectangle. + /// + /// + /// ERROR + /// An error occurred. + /// + /// + /// NULLREGION + /// Region is empty. + /// + /// + /// SIMPLEREGION + /// Region is a single rectangle. + /// + /// + /// + /// + /// The BeginPaint function automatically validates the update region, so any call to GetUpdateRgn made immediately after the + /// call to BeginPaint retrieves an empty update region. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getupdatergn int GetUpdateRgn( HWND hWnd, HRGN hRgn, BOOL + // bErase ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "d80c4b44-3f50-46f9-bf5a-fff7868d91ba")] + public static extern Gdi32.RegionFlags GetUpdateRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase); + + /// + /// + /// The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll + /// bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left + /// corner of the window instead of the client area. + /// + /// + /// GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous + /// attributes are lost. + /// + /// + /// + /// + /// A handle to the window with a device context that is to be retrieved. If this value is NULL, GetWindowDC retrieves + /// the device context for the entire screen. + /// + /// + /// If this parameter is NULL, GetWindowDC retrieves the device context for the primary display monitor. To get the + /// device context for other display monitors, use the EnumDisplayMonitors and CreateDC functions. + /// + /// + /// + /// If the function succeeds, the return value is a handle to a device context for the specified window. + /// If the function fails, the return value is NULL, indicating an error or an invalid hWnd parameter. + /// + /// + /// + /// GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any + /// window is not recommended. + /// + /// + /// The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title + /// bar, menu, and scroll bars. + /// + /// The GetDC function can be used to retrieve a device context for the entire screen. + /// + /// After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device + /// context has serious effects on painting requested by applications. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowdc HDC GetWindowDC( HWND hWnd ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "9e6a135e-e337-4129-a3ad-faf9a8ac9b2d")] + public static extern HDC GetWindowDC(HWND hWnd); + + /// + /// The GetWindowRgn function obtains a copy of the window region of a window. The window region of a window is set by calling + /// the SetWindowRgn function. The window region determines the area within the window where the system permits drawing. The system + /// does not display any portion of a window that lies outside of the window region + /// + /// Handle to the window whose window region is to be obtained. + /// Handle to the region which will be modified to represent the window region. + /// + /// The return value specifies the type of the region that the function obtains. It can be one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// NULLREGION + /// The region is empty. + /// + /// + /// SIMPLEREGION + /// The region is a single rectangle. + /// + /// + /// COMPLEXREGION + /// The region is more than one rectangle. + /// + /// + /// ERROR + /// The specified window does not have a region, or an error occurred while attempting to return the region. + /// + /// + /// + /// + /// + /// 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. + /// + /// To set the window region of a window, call the SetWindowRgn function. + /// Examples + /// The following code shows how you pass in the handle of an existing region. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowrgn int GetWindowRgn( HWND hWnd, HRGN hRgn ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "c8a8fa46-354b-489e-b016-fd2e728958ce")] + public static extern Gdi32.RegionFlags GetWindowRgn(HWND hWnd, HRGN hRgn); + + /// + /// The GetWindowRgnBox function retrieves the dimensions of the tightest bounding rectangle for the window region of a window. + /// + /// Handle to the window. + /// + /// Pointer to a RECT structure that receives the rectangle dimensions, in device units relative to the upper-left corner of the window. + /// + /// + /// The return value specifies the type of the region that the function obtains. It can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// COMPLEXREGION + /// The region is more than one rectangle. + /// + /// + /// ERROR + /// The specified window does not have a region, or an error occurred while attempting to return the region. + /// + /// + /// NULLREGION + /// The region is empty. + /// + /// + /// SIMPLEREGION + /// The region is a single rectangle. + /// + /// + /// + /// + /// + /// The window region determines the area within the window where the system permits drawing. The system does not display any portion + /// of a window that lies outside of the window region. 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. + /// + /// To set the window region of a window, call the SetWindowRgn function. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowrgnbox int GetWindowRgnBox( HWND hWnd, LPRECT + // lprc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "20e23474-a1c5-4afe-976e-a7e5790fb91b")] + public static extern Gdi32.RegionFlags GetWindowRgnBox(HWND hWnd, out RECT lprc); + + /// + /// + /// The GrayString function draws gray text at the specified location. The function draws the text by copying it into a memory + /// bitmap, graying the bitmap, and then copying the bitmap to the screen. The function grays the text regardless of the selected + /// brush and background. GrayString uses the font currently selected for the specified device context. + /// + /// + /// If thelpOutputFuncparameter is NULL, GDI uses the TextOut function, and thelpDataparameter is assumed to be a pointer to + /// the character string to be output. If the characters to be output cannot be handled by TextOut (for example, the string is + /// stored as a bitmap), the application must supply its own output function. + /// + /// + /// A handle to the device context. + /// + /// A handle to the brush to be used for graying. If this parameter is NULL, the text is grayed with the same brush that was + /// used to draw window text. + /// + /// + /// A pointer to the application-defined function that will draw the string, or, if TextOut is to be used to draw the string, it is a + /// NULL pointer. For details, see the OutputProc callback function. + /// + /// + /// A pointer to data to be passed to the output function. If the lpOutputFunc parameter is NULL, lpData must be a pointer to + /// the string to be output. + /// + /// + /// The number of characters to be output. If the nCount parameter is zero, GrayString calculates the length of the string + /// (assuming lpData is a pointer to the string). If nCount is 1 and the function pointed to by lpOutputFunc returns FALSE, + /// the image is shown but not grayed. + /// + /// The device x-coordinate of the starting position of the rectangle that encloses the string. + /// The device y-coordinate of the starting position of the rectangle that encloses the string. + /// + /// The width, in device units, of the rectangle that encloses the string. If this parameter is zero, GrayString calculates + /// the width of the area, assuming lpData is a pointer to the string. + /// + /// + /// The height, in device units, of the rectangle that encloses the string. If this parameter is zero, GrayString calculates + /// the height of the area, assuming lpData is a pointer to the string. + /// + /// + /// If the string is drawn, the return value is nonzero. + /// + /// If either the TextOut function or the application-defined output function returned zero, or there was insufficient memory to + /// create a memory bitmap for graying, the return value is zero. + /// + /// + /// + /// Without calling GrayString, an application can draw grayed strings on devices that support a solid gray color. The system + /// color COLOR_GRAYTEXT is the solid-gray system color used to draw disabled text. The application can call the GetSysColor function + /// to retrieve the color value of COLOR_GRAYTEXT. If the color is other than zero (black), the application can call the SetTextColor + /// function to set the text color to the color value and then draw the string directly. If the retrieved color is black, the + /// application must call GrayString to gray the text. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-graystringa BOOL GrayStringA( HDC hDC, HBRUSH hBrush, + // GRAYSTRINGPROC lpOutputFunc, LPARAM lpData, int nCount, int X, int Y, int nWidth, int nHeight ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "b14b8c40-f97f-4e41-8d8d-687692acfda9")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GrayString(HDC hDC, HBRUSH hBrush, OutputProc lpOutputFunc, string lpData, int nCount, int X, int Y, int nWidth, int nHeight); + + /// + /// 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. + /// + /// + /// A handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all + /// windows, not just the windows for this application, and sends the WM_ERASEBKGND and WM_NCPAINT messages before the function + /// returns. Setting this parameter to NULL is not recommended. + /// + /// + /// A pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this + /// parameter is NULL, the entire client area is added to the update region. + /// + /// + /// Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter + /// is TRUE, the background is erased when the BeginPaint function is called. If this parameter is FALSE, the + /// background remains unchanged. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or + /// until the region is validated by using the ValidateRect or ValidateRgn function. + /// + /// + /// The system sends a WM_PAINT 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 bErase parameter is TRUE for any part of the update region, the background is erased in the entire region, not just + /// in the specified part. + /// + /// Examples + /// For an example, see Invalidating the Client Area. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-invalidaterect BOOL InvalidateRect( HWND hWnd, const RECT + // *lpRect, BOOL bErase ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "5a823d36-d08b-41c9-8857-540576f54b55")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool InvalidateRect(HWND hWnd, [In] PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase); + + /// + /// The InvalidateRgn function invalidates the client area within the specified region by adding it to the current update + /// region of a window. The invalidated region, along with all other areas in the update region, is marked for painting when the next + /// WM_PAINT message occurs. + /// + /// A handle to the window with an update region that is to be modified. + /// + /// A handle to the region to be added to the update region. The region is assumed to have client coordinates. If this parameter is + /// NULL, the entire client area is added to the update region. + /// + /// + /// Specifies whether the background within the update region should be erased when the update region is processed. If this parameter + /// is TRUE, the background is erased when the BeginPaint function is called. If the parameter is FALSE, the background + /// remains unchanged. + /// + /// The return value is always nonzero. + /// + /// + /// Invalidated areas accumulate in the update region until the next WM_PAINT message is processed or until the region is validated + /// by using the ValidateRect or ValidateRgn function. + /// + /// + /// The system sends a WM_PAINT 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 bErase parameter is TRUE for any part of the update region, the background in the entire region is erased, not just + /// in the specified part. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-invalidatergn BOOL InvalidateRgn( HWND hWnd, HRGN hRgn, + // BOOL bErase ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "b5b44efe-8045-4e54-89f9-1766689a053d")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool InvalidateRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase); + + /// + /// The LockWindowUpdate function disables or enables drawing in the specified window. Only one window can be locked at a time. + /// + /// + /// The window in which drawing will be disabled. If this parameter is NULL, drawing in the locked window is enabled. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero, indicating that an error occurred or another window was already locked. + /// + /// + /// + /// The purpose of the LockWindowUpdate function is to permit drag/drop feedback to be drawn over a window without + /// interference from the window itself. The intent is that the window is locked when feedback is drawn and unlocked when feedback is + /// complete. LockWindowUpdate is not intended for general-purpose suppression of window redraw. Use the WM_SETREDRAW message + /// to disable redrawing of a particular window. + /// + /// + /// If an application with a locked window (or any locked child windows) calls the GetDC, GetDCEx, or BeginPaint function, the called + /// function returns a device context with a visible region that is empty. This will occur until the application unlocks the window + /// by calling LockWindowUpdate, specifying a value of NULL for hWndLock. + /// + /// + /// If an application attempts to draw within a locked window, the system records the extent of the attempted operation in a bounding + /// rectangle. When the window is unlocked, the system invalidates the area within this bounding rectangle, forcing an eventual + /// WM_PAINT message to be sent to the previously locked window and its child windows. If no drawing has occurred while the window + /// updates were locked, no area is invalidated. + /// + /// LockWindowUpdate does not make the specified window invisible and does not clear the WS_VISIBLE style bit. + /// A locked window cannot be moved. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-lockwindowupdate BOOL LockWindowUpdate( HWND hWndLock ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "00ec40c7-8ab2-40db-a9bb-48e18d66bf1a")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool LockWindowUpdate(HWND hWndLock); + + /// + /// The PaintDesktop function fills the clipping region in the specified device context with the desktop pattern or wallpaper. + /// The function is provided primarily for shell desktops. + /// + /// Handle to the device context. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-paintdesktop BOOL PaintDesktop( HDC hdc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "738500d4-32f5-43cf-8d40-9ad201ca6d4b")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool PaintDesktop(HDC hdc); + + /// The RedrawWindow function updates the specified rectangle or region in a window's client area. + /// A handle to the window to be redrawn. If this parameter is NULL, the desktop window is updated. + /// + /// A pointer to a RECT structure containing the coordinates, in device units, of the update rectangle. This parameter is ignored if + /// the hrgnUpdate parameter identifies a region. + /// + /// + /// A handle to the update region. If both the hrgnUpdate and lprcUpdate parameters are NULL, the entire client area is added + /// to the update region. + /// + /// + /// + /// 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 RedrawWindow. + /// + /// The following flags are used to invalidate the window. + /// + /// + /// Flag (invalidation) + /// Description + /// + /// + /// RDW_ERASE + /// + /// Causes the window to receive a WM_ERASEBKGND message when the window is repainted. The RDW_INVALIDATE flag must also be + /// specified; otherwise, RDW_ERASE has no effect. + /// + /// + /// + /// RDW_FRAME + /// + /// Causes any part of the nonclient area of the window that intersects the update region to receive a WM_NCPAINT message. The + /// RDW_INVALIDATE flag must also be specified; otherwise, RDW_FRAME has no effect. The WM_NCPAINT message is typically not sent + /// during the execution of RedrawWindow unless either RDW_UPDATENOW or RDW_ERASENOW is specified. + /// + /// + /// + /// RDW_INTERNALPAINT + /// Causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid. + /// + /// + /// RDW_INVALIDATE + /// Invalidates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is invalidated. + /// + /// + /// The following flags are used to validate the window. + /// + /// + /// Flag (validation) + /// Description + /// + /// + /// RDW_NOERASE + /// Suppresses any pending WM_ERASEBKGND messages. + /// + /// + /// RDW_NOFRAME + /// + /// Suppresses any pending WM_NCPAINT messages. This flag must be used with RDW_VALIDATE and is typically used with RDW_NOCHILDREN. + /// RDW_NOFRAME should be used with care, as it could cause parts of a window to be painted improperly. + /// + /// + /// + /// RDW_NOINTERNALPAINT + /// + /// Suppresses any pending internal WM_PAINT messages. This flag does not affect WM_PAINT messages resulting from a non-NULL update area. + /// + /// + /// + /// RDW_VALIDATE + /// + /// Validates lprcUpdate or hrgnUpdate (only one may be non-NULL). If both are NULL, the entire window is validated. This flag does + /// not affect internal WM_PAINT messages. + /// + /// + /// + /// + /// The following flags control when repainting occurs. RedrawWindow will not repaint unless one of these flags is specified. + /// + /// + /// + /// Flag + /// Description + /// + /// + /// RDW_ERASENOW + /// + /// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT and + /// WM_ERASEBKGND messages, if necessary, before the function returns. WM_PAINT messages are received at the ordinary time. + /// + /// + /// + /// RDW_UPDATENOW + /// + /// Causes the affected windows (as specified by the RDW_ALLCHILDREN and RDW_NOCHILDREN flags) to receive WM_NCPAINT, WM_ERASEBKGND, + /// and WM_PAINT messages, if necessary, before the function returns. + /// + /// + /// + /// + /// By default, the windows affected by RedrawWindow depend on whether the specified window has the WS_CLIPCHILDREN style. + /// Child windows that are not the WS_CLIPCHILDREN style are unaffected; non-WS_CLIPCHILDREN windows are recursively validated or + /// invalidated until a WS_CLIPCHILDREN window is encountered. The following flags control which windows are affected by the + /// RedrawWindow function. + /// + /// + /// + /// Flag + /// Description + /// + /// + /// RDW_ALLCHILDREN + /// Includes child windows, if any, in the repainting operation. + /// + /// + /// RDW_NOCHILDREN + /// Excludes child windows, if any, from the repainting operation. + /// + /// + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// When RedrawWindow is used to invalidate part of the desktop window, the desktop window does not receive a WM_PAINT + /// message. To repaint the desktop, an application uses the RDW_ERASE flag to generate a WM_ERASEBKGND message. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-redrawwindow BOOL RedrawWindow( HWND hWnd, const RECT + // *lprcUpdate, HRGN hrgnUpdate, UINT flags ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "c6cb7f74-237e-4d3e-a852-894da36e990c")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool RedrawWindow(HWND hWnd, [In] PRECT lprcUpdate, HRGN hrgnUpdate, RedrawWindowFlags flags); + + /// + /// The SetWindowRgn function sets the window region of a window. The window region determines the area within the window + /// where the system permits drawing. The system does not display any portion of a window that lies outside of the window region + /// + /// A handle to the window whose window region is to be set. + /// + /// A handle to a region. The function sets the window region of the window to this region. + /// If hRgn is NULL, the function sets the window region to NULL. + /// + /// + /// + /// Specifies whether the system redraws the window after setting the window region. If bRedraw is TRUE, the system does so; + /// otherwise, it does not. + /// + /// Typically, you set bRedraw to TRUE if the window is visible. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// When this function is called, the system sends the WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGING 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. + /// + /// + /// Note If the window layout is right-to-left (RTL), the coordinates are relative to the upper-right corner of the window. + /// See Window Layout and Mirroring. + /// + /// + /// After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. 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 GetWindowRgn function. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowrgn int SetWindowRgn( HWND hWnd, HRGN hRgn, BOOL + // bRedraw ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "06209d0c-14f9-45ec-ae2c-9cc596b5bbaa")] + public static extern int SetWindowRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bRedraw); + + /// + /// 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. The function sends a WM_PAINT message directly to the window procedure of the + /// specified window, bypassing the application queue. If the update region is empty, no message is sent. + /// + /// Handle to the window to be updated. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-updatewindow BOOL UpdateWindow( HWND hWnd ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "51a50f1f-7b4d-4acd-83a0-1877f5181766")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool UpdateWindow(HWND hWnd); + + /// + /// The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of + /// the specified window. + /// + /// + /// Handle to the window whose update region is to be modified. If this parameter is NULL, the system invalidates and redraws + /// all windows and sends the WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the function returns. + /// + /// + /// Pointer to a RECT structure that contains the client coordinates of the rectangle to be removed from the update region. If this + /// parameter is NULL, the entire client area is removed. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRgn function + /// should be called if a portion of the update region must be validated before the next WM_PAINT message is generated. + /// + /// The system continues to generate WM_PAINT messages until the current update region is validated. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-validaterect BOOL ValidateRect( HWND hWnd, const RECT + // *lpRect ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "961dd768-1849-44df-bc7f-480881ed6477")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ValidateRect(HWND hWnd, [In] PRECT lpRect); + + /// + /// The ValidateRgn function validates the client area within a region by removing the region from the current update region + /// of the specified window. + /// + /// Handle to the window whose update region is to be modified. + /// + /// Handle to a region that defines the area to be removed from the update region. If this parameter is NULL, the entire + /// client area is removed. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// The specified region must have been created by a region function. The region coordinates are assumed to be client coordinates. + /// + /// The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRgn function + /// should be called if a portion of the update region must be validated before the next WM_PAINT message is generated. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-validatergn BOOL ValidateRgn( HWND hWnd, HRGN hRgn ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "80fb1d4a-d9b1-4e67-b585-eee81893ed34")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ValidateRgn(HWND hWnd, HRGN hRgn); + + /// + /// + /// The PAINTSTRUCT structure contains information for an application. This information can be used to paint the client area + /// of a window owned by that application. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagpaintstruct typedef struct tagPAINTSTRUCT { HDC hdc; + // BOOL fErase; RECT rcPaint; BOOL fRestore; BOOL fIncUpdate; BYTE rgbReserved[32]; } PAINTSTRUCT, *PPAINTSTRUCT, *NPPAINTSTRUCT, *LPPAINTSTRUCT; + [PInvokeData("winuser.h", MSDNShortId = "1f8c6dd2-e511-48f2-8ab0-d2fadb1ce433")] + [StructLayout(LayoutKind.Sequential)] + public struct PAINTSTRUCT + { + /// + /// A handle to the display DC to be used for painting. + /// + public HDC hdc; + + /// + /// + /// Indicates whether the background must be erased. This value is nonzero if the application should erase the background. The + /// application is responsible for erasing the background if a window class is created without a background brush. For more + /// information, see the description of the hbrBackground member of the WNDCLASS structure. + /// + /// + [MarshalAs(UnmanagedType.Bool)] + public bool fErase; + + /// + /// + /// A RECT structure that specifies the upper left and lower right corners of the rectangle in which the painting is requested, + /// in device units relative to the upper-left corner of the client area. + /// + /// + public RECT rcPaint; + + /// + /// Reserved; used internally by the system. + /// + [MarshalAs(UnmanagedType.Bool)] + public bool fRestore; + + /// + /// Reserved; used internally by the system. + /// + [MarshalAs(UnmanagedType.Bool)] + public bool fIncUpdate; + + /// + /// Reserved; used internally by the system. + /// + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] rgbReserved; + } + } +} \ No newline at end of file diff --git a/PInvoke/User32.Gdi/WinUser.Rect.cs b/PInvoke/User32.Gdi/WinUser.Rect.cs new file mode 100644 index 00000000..6af2184a --- /dev/null +++ b/PInvoke/User32.Gdi/WinUser.Rect.cs @@ -0,0 +1,307 @@ +using System.Drawing; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class User32_Gdi + { + /// The CopyRect function copies the coordinates of one rectangle to another. + /// Pointer to the RECT structure that receives the logical coordinates of the source rectangle. + /// Pointer to the RECT structure whose coordinates are to be copied in logical units. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-copyrect BOOL CopyRect( LPRECT lprcDst, const RECT + // *lprcSrc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "9349ba83-59d6-49d0-ac9d-a4d9589748dd")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CopyRect(out RECT lprcDst, in RECT lprcSrc); + + /// + /// The EqualRect function determines whether the two specified rectangles are equal by comparing the coordinates of their + /// upper-left and lower-right corners. + /// + /// Pointer to a RECT structure that contains the logical coordinates of the first rectangle. + /// Pointer to a RECT structure that contains the logical coordinates of the second rectangle. + /// + /// If the two rectangles are identical, the return value is nonzero. + /// If the two rectangles are not identical, the return value is zero. + /// + /// + /// The EqualRect function does not treat empty rectangles as equal if their coordinates are different. + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-equalrect BOOL EqualRect( const RECT *lprc1, const RECT + // *lprc2 ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "00763184-6b60-4095-b71e-5a851c2643aa")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EqualRect(in RECT lprc1, in RECT lprc2); + + /// + /// The InflateRect function increases or decreases the width and height of the specified rectangle. The InflateRect + /// function adds dx units to the left and right ends of the rectangle and dy units to the top and bottom. The dx and dy parameters + /// are signed values; positive values increase the width and height, and negative values decrease them. + /// + /// A pointer to the RECT structure that increases or decreases in size. + /// The amount to increase or decrease the rectangle width. This parameter must be negative to decrease the width. + /// The amount to increase or decrease the rectangle height. This parameter must be negative to decrease the height. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-inflaterect BOOL InflateRect( LPRECT lprc, int dx, int dy ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "9a52fb7f-cd35-4426-8753-c26cebef30d5")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool InflateRect(ref RECT lprc, int dx, int dy); + + /// + /// The IntersectRect function calculates the intersection of two source rectangles and places the coordinates of the + /// intersection rectangle into the destination rectangle. If the source rectangles do not intersect, an empty rectangle (in which + /// all coordinates are set to zero) is placed into the destination rectangle. + /// + /// + /// A pointer to the RECT structure that is to receive the intersection of the rectangles pointed to by the lprcSrc1 and lprcSrc2 + /// parameters. This parameter cannot be NULL. + /// + /// A pointer to the RECT structure that contains the first source rectangle. + /// A pointer to the RECT structure that contains the second source rectangle. + /// + /// If the rectangles intersect, the return value is nonzero. + /// If the rectangles do not intersect, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-intersectrect BOOL IntersectRect( LPRECT lprcDst, const + // RECT *lprcSrc1, const RECT *lprcSrc2 ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "da686f78-e557-4ff2-9f24-b229f0c01563")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool IntersectRect(out RECT lprcDst, in RECT lprcSrc1, in RECT lprcSrc2); + + /// + /// The IsRectEmpty function determines whether the specified rectangle is empty. An empty rectangle is one that has no area; + /// that is, the coordinate of the right side is less than or equal to the coordinate of the left side, or the coordinate of the + /// bottom side is less than or equal to the coordinate of the top side. + /// + /// Pointer to a RECT structure that contains the logical coordinates of the rectangle. + /// + /// If the rectangle is empty, the return value is nonzero. + /// If the rectangle is not empty, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-isrectempty BOOL IsRectEmpty( const RECT *lprc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "9deeed4f-304e-47a3-8259-ed7bc3815fd7")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool IsRectEmpty(in RECT lprc); + + /// The OffsetRect function moves the specified rectangle by the specified offsets. + /// Pointer to a RECT structure that contains the logical coordinates of the rectangle to be moved. + /// + /// Specifies the amount to move the rectangle left or right. This parameter must be a negative value to move the rectangle to the left. + /// + /// + /// Specifies the amount to move the rectangle up or down. This parameter must be a negative value to move the rectangle up. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-offsetrect BOOL OffsetRect( LPRECT lprc, int dx, int dy ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "14101ad3-8c6e-459a-974a-1a8a4d8d7906")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool OffsetRect(ref RECT lprc, int dx, int dy); + + /// + /// The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a + /// rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered + /// outside the rectangle. + /// + /// A pointer to a RECT structure that contains the specified rectangle. + /// A POINT structure that contains the specified point. + /// + /// If the specified point lies within the rectangle, the return value is nonzero. + /// If the specified point does not lie within the rectangle, the return value is zero. + /// + /// + /// + /// The rectangle must be normalized before PtInRect is called. That is, lprc.right must be greater than lprc.left and + /// lprc.bottom must be greater than lprc.top. If the rectangle is not normalized, a point is never considered inside of the rectangle. + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-ptinrect BOOL PtInRect( const RECT *lprc, POINT pt ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "8a47a238-082c-44b8-a270-5ebb4d3d9fc8")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool PtInRect(in RECT lprc, Point pt); + + /// + /// The SetRect function sets the coordinates of the specified rectangle. This is equivalent to assigning the left, top, + /// right, and bottom arguments to the appropriate members of the RECT structure. + /// + /// Pointer to the RECT structure that contains the rectangle to be set. + /// Specifies the x-coordinate of the rectangle's upper-left corner. + /// Specifies the y-coordinate of the rectangle's upper-left corner. + /// Specifies the x-coordinate of the rectangle's lower-right corner. + /// Specifies the y-coordinate of the rectangle's lower-right corner. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setrect BOOL SetRect( LPRECT lprc, int xLeft, int yTop, + // int xRight, int yBottom ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "346c573b-eaf7-4ca6-bd36-18074f7eccf5")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetRect(out RECT lprc, int xLeft, int yTop, int xRight, int yBottom); + + /// The SetRectEmpty function creates an empty rectangle in which all coordinates are set to zero. + /// Pointer to the RECT structure that contains the coordinates of the rectangle. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. + /// + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// Examples + /// For an example, see Using Rectangles. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setrectempty BOOL SetRectEmpty( LPRECT lprc ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "d3c677ae-e45c-4d54-8521-75954a466a68")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SetRectEmpty(ref RECT lprc); + + /// + /// The SubtractRect function determines the coordinates of a rectangle formed by subtracting one rectangle from another. + /// + /// + /// A pointer to a RECT structure that receives the coordinates of the rectangle determined by subtracting the rectangle pointed to + /// by lprcSrc2 from the rectangle pointed to by lprcSrc1. + /// + /// A pointer to a RECT structure from which the function subtracts the rectangle pointed to by lprcSrc2. + /// A pointer to a RECT structure that the function subtracts from the rectangle pointed to by lprcSrc1. + /// + /// If the resulting rectangle is empty, the return value is zero. + /// If the resulting rectangle is not empty, the return value is nonzero. + /// + /// + /// + /// The function only subtracts the rectangle specified by lprcSrc2 from the rectangle specified by lprcSrc1 when the rectangles + /// intersect completely in either the x- or y-direction. For example, if *lprcSrc1 has the coordinates (10,10,100,100) and *lprcSrc2 + /// has the coordinates (50,50,150,150), the function sets the coordinates of the rectangle pointed to by lprcDst to (10,10,100,100). + /// If *lprcSrc1 has the coordinates (10,10,100,100) and *lprcSrc2 has the coordinates (50,10,150,150), however, the function sets + /// the coordinates of the rectangle pointed to by lprcDst to (10,10,50,100). In other words, the resulting rectangle is the bounding + /// box of the geometric difference. + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-subtractrect BOOL SubtractRect( LPRECT lprcDst, const RECT + // *lprcSrc1, const RECT *lprcSrc2 ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "85c8edae-af2b-4c6c-af37-2631e8b4edcd")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SubtractRect(out RECT lprcDst, in RECT lprcSrc1, in RECT lprcSrc2); + + /// + /// The UnionRect function creates the union of two rectangles. The union is the smallest rectangle that contains both source rectangles. + /// + /// + /// A pointer to the RECT structure that will receive a rectangle containing the rectangles pointed to by the lprcSrc1 and lprcSrc2 parameters. + /// + /// A pointer to the RECT structure that contains the first source rectangle. + /// A pointer to the RECT structure that contains the second source rectangle. + /// + /// If the specified structure contains a nonempty rectangle, the return value is nonzero. + /// If the specified structure does not contain a nonempty rectangle, the return value is zero. + /// + /// + /// + /// The system ignores the dimensions of an empty rectangle that is, a rectangle in which all coordinates are set to zero, so that it + /// has no height or no width. + /// + /// + /// Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. + /// Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which + /// the rectangle is used determine the units of measure. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-unionrect BOOL UnionRect( LPRECT lprcDst, const RECT + // *lprcSrc1, const RECT *lprcSrc2 ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "f2da2df4-3f09-4c54-afd1-c728805f0f64")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool UnionRect(out RECT lprcDst, in RECT lprcSrc1, in RECT lprcSrc2); + } +} \ No newline at end of file