Added video, accelerator, caret, coordinate space, paint and RECT functions

pull/47/head
David Hall 2019-02-05 14:13:14 -07:00
parent c1af977137
commit 47599ad6f2
6 changed files with 3203 additions and 0 deletions

287
PInvoke/User32.Gdi/TvOut.cs Normal file
View File

@ -0,0 +1,287 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32_Gdi
{
/// <summary>Specifies whether to retrieve or set the values that are indicated by the other members of <see cref="VIDEOPARAMETERS"/>.</summary>
[PInvokeData("Tvout.h")]
public enum VP_COMMAND : uint
{
/// <summary>Gets current video capabilities. If capability is not supported, dwFlags is 0.</summary>
VP_COMMAND_GET = 0x0001,
/// <summary>Sets video parameters.</summary>
VP_COMMAND_SET = 0x0002,
}
/// <summary>The copy protection command.</summary>
[PInvokeData("Tvout.h")]
public enum VP_CP_CMD : uint
{
/// <summary>Activate copy protection.</summary>
VP_CP_CMD_ACTIVATE = 0x0001,
/// <summary>Deactivate copy protection.</summary>
VP_CP_CMD_DEACTIVATE = 0x0002,
/// <summary>Change copy protection.</summary>
VP_CP_CMD_CHANGE = 0x0004,
}
/// <summary>The copy protection type. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
[PInvokeData("Tvout.h")]
public enum VP_CP_TYPE : uint
{
/// <summary>Only DVD trigger bits available.</summary>
VP_CP_TYPE_APS_TRIGGER = 0x0001,
/// <summary>Full Macrovision data is available.</summary>
VP_CP_TYPE_MACROVISION = 0x0002,
}
/// <summary>
/// Indicates which fields of <see cref="VIDEOPARAMETERS"/> contain valid data. For VP_COMMAND_GET, this should be zero. For
/// VP_COMMAND_SET, these are the fields to set.
/// </summary>
[PInvokeData("Tvout.h")]
public enum VP_FLAGS : uint
{
/// <summary>dwMode (for VP_COMMAND_GET and VP_COMMAND_SET) and dwAvailableModes (for VP_COMMAND_GET).</summary>
VP_FLAGS_TV_MODE = 0x0001,
/// <summary>dwTVStandard (for VP_COMMAND_GET and VP_COMMAND_SET) and dwAvailableTVStandard (for VP_COMMAND_GET).</summary>
VP_FLAGS_TV_STANDARD = 0x0002,
/// <summary>dwFlickerFilter (for VP_COMMAND_GET and VP_COMMAND_SET).</summary>
VP_FLAGS_FLICKER = 0x0004,
/// <summary>dwOverScanX, dwOverScanY (for VP_COMMAND_GET and VP_COMMAND_SET).</summary>
VP_FLAGS_OVERSCAN = 0x0008,
/// <summary>dwMaxUnscaledX, dwMaxUnscaledY (for VP_COMMAND_GET).</summary>
VP_FLAGS_MAX_UNSCALED = 0x0010,
/// <summary>dwPositionX, dwPositionY (for VP_COMMAND_GET and VP_COMMAND_SET).</summary>
VP_FLAGS_POSITION = 0x0020,
/// <summary>dwBrightness (for VP_COMMAND_GET and VP_COMMAND_SET).</summary>
VP_FLAGS_BRIGHTNESS = 0x0040,
/// <summary>dwContrast (for VP_COMMAND_GET and VP_COMMAND_SET).</summary>
VP_FLAGS_CONTRAST = 0x0080,
/// <summary>
/// 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).
/// </summary>
VP_FLAGS_COPYPROTECT = 0x0100,
}
/// <summary>The current playback mode. This member is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
[PInvokeData("Tvout.h")]
public enum VP_MODE : uint
{
/// <summary>
/// Describes a set of display settings that are optimal for Windows display, with the flicker filter on and any overscan display off.
/// </summary>
VP_MODE_WIN_GRAPHICS = 0x0001,
/// <summary>
/// Describes a set of display settings for video playback, with the flicker filter off and the overscan display on.
/// </summary>
VP_MODE_TV_PLAYBACK = 0x0002,
}
/// <summary>The TV standard. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
[PInvokeData("Tvout.h")]
public enum VP_TV : uint
{
/// <summary>NTSC m</summary>
VP_TV_STANDARD_NTSC_M = 0x0001,
/// <summary>NTSC m j</summary>
VP_TV_STANDARD_NTSC_M_J = 0x0002,
/// <summary>pal b</summary>
VP_TV_STANDARD_PAL_B = 0x0004,
/// <summary>pal d</summary>
VP_TV_STANDARD_PAL_D = 0x0008,
/// <summary>pal h</summary>
VP_TV_STANDARD_PAL_H = 0x0010,
/// <summary>pal i</summary>
VP_TV_STANDARD_PAL_I = 0x0020,
/// <summary>pal m</summary>
VP_TV_STANDARD_PAL_M = 0x0040,
/// <summary>pal n</summary>
VP_TV_STANDARD_PAL_N = 0x0080,
/// <summary>secam b</summary>
VP_TV_STANDARD_SECAM_B = 0x0100,
/// <summary>secam d</summary>
VP_TV_STANDARD_SECAM_D = 0x0200,
/// <summary>secam g</summary>
VP_TV_STANDARD_SECAM_G = 0x0400,
/// <summary>secam h</summary>
VP_TV_STANDARD_SECAM_H = 0x0800,
/// <summary>secam k</summary>
VP_TV_STANDARD_SECAM_K = 0x1000,
/// <summary>secam k1</summary>
VP_TV_STANDARD_SECAM_K1 = 0x2000,
/// <summary>secam l</summary>
VP_TV_STANDARD_SECAM_L = 0x4000,
/// <summary>win vga</summary>
VP_TV_STANDARD_WIN_VGA = 0x8000,
/// <summary>NTSC 433</summary>
VP_TV_STANDARD_NTSC_433 = 0x00010000,
/// <summary>pal g</summary>
VP_TV_STANDARD_PAL_G = 0x00020000,
/// <summary>pal 60</summary>
VP_TV_STANDARD_PAL_60 = 0x00040000,
/// <summary>secam l1</summary>
VP_TV_STANDARD_SECAM_L1 = 0x00080000,
}
/// <summary>The <c>VIDEOPARAMETERS</c> structure contains information for a video connection.</summary>
// 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
{
/// <summary>
/// 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.
/// </summary>
public Guid guid;
/// <summary>Reserved; must be zero.</summary>
public uint dwOffset;
/// <summary>Specifies whether to retrieve or set the values that are indicated by the other members of this structure.</summary>
public VP_COMMAND dwCommand;
/// <summary>
/// Indicates which fields contain valid data. For VP_COMMAND_GET, this should be zero. For VP_COMMAND_SET, these are the fields
/// to set.
/// </summary>
public VP_FLAGS dwFlags;
/// <summary>The current playback mode. This member is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
public VP_MODE dwMode;
/// <summary>The TV standard. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
public VP_TV dwTVStandard;
/// <summary>
/// Specifies which modes are available. This is valid only for VP_COMMAND_GET. It can be any combination of the values specified
/// in dwMode.
/// </summary>
public VP_MODE dwAvailableModes;
/// <summary>
/// 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.
/// </summary>
public VP_TV dwAvailableTVStandard;
/// <summary>
/// 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.
/// </summary>
public uint dwFlickerFilter;
/// <summary>
/// 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.
/// </summary>
public uint dwOverScanX;
/// <summary>
/// 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.
/// </summary>
public uint dwOverScanY;
/// <summary>
/// The maximum horizontal resolution, in pixels, that is supported when the video is not scaled. This field is valid for both VP_COMMAND_GET.
/// </summary>
public uint dwMaxUnscaledX;
/// <summary>
/// The maximum vertical resolution, in pixels, that is supported when the video is not scaled. This field is valid for both VP_COMMAND_GET.
/// </summary>
public uint dwMaxUnscaledY;
/// <summary>
/// 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.
/// </summary>
public uint dwPositionX;
/// <summary>
/// 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.
/// </summary>
public uint dwPositionY;
/// <summary>
/// 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.
/// </summary>
public uint dwBrightness;
/// <summary>
/// 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.
/// </summary>
public uint dwContrast;
/// <summary>The copy protection type. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET.</summary>
public VP_CP_TYPE dwCPType;
/// <summary>The copy protection command. This field is only valid for VP_COMMAND_SET.</summary>
public VP_CP_CMD dwCPCommand;
/// <summary>Specifies TV standards for which copy protection types are available. This field is valid only for VP_COMMAND_GET.</summary>
public uint dwCPStandard;
/// <summary>
/// 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.
/// </summary>
public uint dwCPKey;
/// <summary>The DVD APS trigger bit flag. This is valid only for VP_COMMAND_SET. Currently, only bits 0 and 1 are valid.</summary>
public uint bCP_APSTriggerBits;
/// <summary>
/// The OEM-specific copy protection data. Maximum of 256 characters. This field is valid for both VP_COMMAND_GET and VP_COMMAND_SET.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string bOEMCopyProtection;
}
}
}

View File

@ -0,0 +1,271 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32_Gdi
{
/// <summary>Flags used by <see cref="ACCEL.fVirt"/>.</summary>
[PInvokeData("winuser.h")]
[Flags]
public enum FVIRT : byte
{
/// <summary>
/// The key member specifies a virtual-key code. If this flag is not specified, key is assumed to specify a character code.
/// </summary>
FVIRTKEY = 0x01,
/// <summary>
/// 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.
/// </summary>
FNOINVERT = 0x02,
/// <summary>The SHIFT key must be held down when the accelerator key is pressed.</summary>
FSHIFT = 0x04,
/// <summary>The CTRL key must be held down when the accelerator key is pressed.</summary>
FCONTROL = 0x08,
/// <summary>The ALT key must be held down when the accelerator key is pressed.</summary>
FALT = 0x10,
}
/// <summary>
/// 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.
/// </summary>
/// <param name="hAccelSrc">
/// <para>Type: <c>HACCEL</c></para>
/// <para>A handle to the accelerator table to copy.</para>
/// </param>
/// <param name="lpAccelDst">
/// <para>Type: <c>LPACCEL</c></para>
/// <para>An array of ACCEL structures that receives the accelerator-table information.</para>
/// </param>
/// <param name="cAccelEntries">
/// <para>Type: <c>int</c></para>
/// <para>The number of ACCEL structures to copy to the buffer pointed to by the lpAccelDst parameter.</para>
/// </param>
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>
/// If lpAccelDst is <c>NULL</c>, 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.
/// </para>
/// </returns>
// 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);
/// <summary>Creates an accelerator table.</summary>
/// <param name="paccel">
/// <para>Type: <c>LPACCEL</c></para>
/// <para>An array of ACCEL structures that describes the accelerator table.</para>
/// </param>
/// <param name="cAccel">
/// <para>Type: <c>int</c></para>
/// <para>The number of ACCEL structures in the array. This must be within the range 1 to 32767 or the function will fail.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HACCEL</c></para>
/// <para>
/// If the function succeeds, the return value is the handle to the created accelerator table; otherwise, it is <c>NULL</c>. To get
/// extended error information, call GetLastError.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// Before an application closes, it can use the DestroyAcceleratorTable function to destroy any accelerator tables that it created
/// by using the <c>CreateAcceleratorTable</c> function.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating User Editable Accelerators.</para>
/// </remarks>
// 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);
/// <summary>Destroys an accelerator table.</summary>
/// <param name="hAccel">
/// <para>Type: <c>HACCEL</c></para>
/// <para>
/// A handle to the accelerator table to be destroyed. This handle must have been created by a call to the CreateAcceleratorTable or
/// LoadAccelerators function.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>
/// 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 <c>DestroyAcceleratorTable</c> has been called an equal
/// number of times.
/// </para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
// 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);
/// <summary>Loads the specified accelerator table.</summary>
/// <param name="hInstance">
/// <para>Type: <c>HINSTANCE</c></para>
/// <para>A handle to the module whose executable file contains the accelerator table to be loaded.</para>
/// </param>
/// <param name="lpTableName">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>
/// 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.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HACCEL</c></para>
/// <para>If the function succeeds, the return value is a handle to the loaded accelerator table.</para>
/// <para>If the function fails, the return value is <c>NULL</c>. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>If the accelerator table has not yet been loaded, the function loads it from the specified executable file.</para>
/// <para>Accelerator tables loaded from resources are freed automatically when the application terminates.</para>
/// <para>Examples</para>
/// <para>For an example, see Creating Accelerators for Font Attributes.</para>
/// </remarks>
// 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);
/// <summary>
/// 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 <c>WM_COMMAND</c>
/// or <c>WM_SYSCOMMAND</c> message directly to the specified window procedure. <c>TranslateAccelerator</c> does not return until the
/// window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>A handle to the window whose messages are to be translated.</para>
/// </param>
/// <param name="hAccTable">
/// <para>Type: <c>HACCEL</c></para>
/// <para>
/// 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.
/// </para>
/// </param>
/// <param name="lpMsg">
/// <para>Type: <c>LPMSG</c></para>
/// <para>
/// A pointer to an MSG structure that contains message information retrieved from the calling thread's message queue using the
/// GetMessage or PeekMessage function.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>
/// Accelerator key combinations used to select items from the <c>window</c> menu are translated into WM_SYSCOMMAND messages; all
/// other accelerator key combinations are translated into WM_COMMAND messages.
/// </para>
/// <para>
/// When <c>TranslateAccelerator</c> returns a nonzero value and the message is translated, the application should not use the
/// TranslateMessage function to process the message again.
/// </para>
/// <para>An accelerator need not correspond to a menu command.</para>
/// <para>
/// 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:
/// </para>
/// <list type="bullet">
/// <item>
/// <term>The window is disabled.</term>
/// </item>
/// <item>
/// <term>The accelerator key combination does not correspond to an item on the <c>window</c> menu and the window is minimized.</term>
/// </item>
/// <item>
/// <term>A mouse capture is in effect. For information about mouse capture, see the SetCapture function.</term>
/// </item>
/// </list>
/// <para>
/// 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), <c>TranslateAccelerator</c> translates WM_SYSKEYUP and WM_SYSKEYDOWN messages instead of WM_KEYUP and WM_KEYDOWN messages.
/// </para>
/// <para>
/// If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized,
/// <c>TranslateAccelerator</c> 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 <c>window</c> menu, the function sends a <c>WM_COMMAND</c> message, even if the
/// window is minimized.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating Accelerators for Font Attributes.</para>
/// </remarks>
// 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);
/// <summary>
/// <para>Defines an accelerator key used in an accelerator table.</para>
/// </summary>
// 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
{
/// <summary>The accelerator behavior. This member can be one or more of the following values.</summary>
public FVIRT fVirt;
/// <summary>
/// <para>Type: <c>WORD</c></para>
/// <para>The accelerator key. This member can be either a virtual-key code or a character code.</para>
/// </summary>
public ushort key;
/// <summary>
/// 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.
/// </summary>
public ushort cmd;
}
/// <summary>Provides a <see cref="SafeHandle"/> for <see cref="HACCEL"/> that is disposed using <see cref="DestroyAcceleratorTable"/>.</summary>
public class SafeHACCEL : SafeHANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHACCEL"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHACCEL(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="SafeHACCEL"/> class.</summary>
private SafeHACCEL() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHACCEL"/> to <see cref="HACCEL"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HACCEL(SafeHACCEL h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DestroyAcceleratorTable(this);
}
}
}

View File

@ -0,0 +1,270 @@
using System.Drawing;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32_Gdi
{
/// <summary>
/// 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.
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>A handle to the window that owns the caret.</para>
/// </param>
/// <param name="hBitmap">
/// <para>Type: <c>HBITMAP</c></para>
/// <para>
/// A handle to the bitmap that defines the caret shape. If this parameter is <c>NULL</c>, 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.
/// </para>
/// <para>
/// If hBitmap is a bitmap handle, <c>CreateCaret</c> ignores the nWidth and nHeight parameters; the bitmap defines its own width and height.
/// </para>
/// </param>
/// <param name="nWidth">
/// <para>Type: <c>int</c></para>
/// <para>
/// 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, <c>CreateCaret</c> ignores this parameter.
/// </para>
/// </param>
/// <param name="nHeight">
/// <para>Type: <c>int</c></para>
/// <para>
/// 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, <c>CreateCaret</c> ignores this parameter.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>
/// <c>CreateCaret</c> 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.
/// </para>
/// <para>
/// The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The
/// window should destroy the caret before losing the keyboard focus or becoming inactive.
/// </para>
/// <para>DPI Virtualization</para>
/// <para>
/// 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.
/// </para>
/// </remarks>
// 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);
/// <summary>Destroys the caret's current shape, frees the caret from the window, and removes the caret from the screen.</summary>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>DestroyCaret</c> 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, <c>DestroyCaret</c> does nothing and returns <c>FALSE</c>.
/// </para>
/// <para>
/// The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The
/// window should destroy the caret before losing the keyboard focus or becoming inactive.
/// </para>
/// <para>For an example, see Destroying a Caret</para>
/// </remarks>
// 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();
/// <summary>Retrieves the time required to invert the caret's pixels. The user can set this value.</summary>
/// <returns>
/// <para>Type: <c>UINT</c></para>
/// <para>If the function succeeds, the return value is the blink time, in milliseconds.</para>
/// <para>A return value of <c>INFINITE</c> indicates that the caret does not blink.</para>
/// <para>A return value is zero indicates that the function has failed. To get extended error information, call GetLastError.</para>
/// </returns>
// 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();
/// <summary>Copies the caret's position to the specified POINT structure.</summary>
/// <param name="lpPoint">
/// <para>Type: <c>LPPOINT</c></para>
/// <para>A pointer to the POINT structure that is to receive the client coordinates of the caret.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>The caret position is always given in the client coordinates of the window that contains the caret.</para>
/// <para>DPI Virtualization</para>
/// <para>
/// This API does not participate in DPI virtualization. The returned values are interpreted as logical sizes in terms of the window
/// in question. The calling thread is not taken into consideration.
/// </para>
/// </remarks>
// 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);
/// <summary>
/// Removes the caret from the screen. Hiding a caret does not destroy its current shape or invalidate the insertion point.
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>
/// A handle to the window that owns the caret. If this parameter is <c>NULL</c>, <c>HideCaret</c> searches the current task for the
/// window that owns the caret.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>HideCaret</c> hides the caret only if the specified window owns the caret. If the specified window does not own the caret,
/// <c>HideCaret</c> does nothing and returns <c>FALSE</c>.
/// </para>
/// <para>
/// Hiding is cumulative. If your application calls <c>HideCaret</c> five times in a row, it must also call ShowCaret five times
/// before the caret is displayed.
/// </para>
/// <para>For an example, see Hiding a Caret.</para>
/// </remarks>
// 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);
/// <summary>
/// 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.
/// </summary>
/// <param name="uMSeconds">
/// <para>Type: <c>UINT</c></para>
/// <para>The new blink time, in milliseconds.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// The user can set the blink time using the Control Panel. Applications should respect the setting that the user has chosen. The
/// <c>SetCaretBlinkTime</c> function should only be used by application that allow the user to set the blink time, such as a Control
/// Panel applet.
/// </para>
/// <para>
/// 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.
/// </para>
/// </remarks>
// 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);
/// <summary>
/// Moves the caret to the specified coordinates. If the window that owns the caret was created with the <c>CS_OWNDC</c> class style,
/// then the specified coordinates are subject to the mapping mode of the device context associated with that window.
/// </summary>
/// <param name="X">
/// <para>Type: <c>int</c></para>
/// <para>The new x-coordinate of the caret.</para>
/// </param>
/// <param name="Y">
/// <para>Type: <c>int</c></para>
/// <para>The new y-coordinate of the caret.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para><c>SetCaretPos</c> moves the caret whether the caret is hidden.</para>
/// <para>
/// 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.
/// </para>
/// <para>DPI Virtualization</para>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating and Displaying a Caret.</para>
/// </remarks>
// 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);
/// <summary>
/// Makes the caret visible on the screen at the caret's current position. When the caret becomes visible, it begins flashing automatically.
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>
/// A handle to the window that owns the caret. If this parameter is <c>NULL</c>, <c>ShowCaret</c> searches the current task for the
/// window that owns the caret.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// <c>ShowCaret</c> 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, <c>ShowCaret</c> does nothing and returns <c>FALSE</c>.
/// </para>
/// <para>
/// Hiding is cumulative. If your application calls HideCaret five times in a row, it must also call <c>ShowCaret</c> five times
/// before the caret reappears.
/// </para>
/// <para>
/// The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The
/// window should destroy the caret before losing the keyboard focus or becoming inactive.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating and Displaying a Caret.</para>
/// </remarks>
// 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);
}
}

View File

@ -0,0 +1,201 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32_Gdi
{
/// <summary>
/// <para>Indicates the screen orientation preference for a desktop app process.</para>
/// </summary>
// 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
{
/// <summary>The process has no device orientation preferences. The system may choose any available setting.</summary>
ORIENTATION_PREFERENCE_NONE = 0x00,
/// <summary>The process represents a desktop app that can be used in landscape mode.</summary>
ORIENTATION_PREFERENCE_LANDSCAPE = 0x01,
/// <summary>The process represents a desktop app that can be used in portrait mode.</summary>
ORIENTATION_PREFERENCE_PORTRAIT = 0x02,
/// <summary>The process represents a desktop app that can be used in flipped landscape mode.</summary>
ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = 0x04,
/// <summary>The process represents a desktop app that can be used in flipped portrait mode.</summary>
ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = 0x08,
}
/// <summary>The <c>ClientToScreen</c> function converts the client-area coordinates of a specified point to screen coordinates.</summary>
/// <param name="hWnd">A handle to the window whose client area is used for the conversion.</param>
/// <param name="lpPoint">
/// A pointer to a POINT structure that contains the client coordinates to be converted. The new screen coordinates are copied into
/// this structure if the function succeeds.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>ClientToScreen</c> 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.
/// </para>
/// <para>All coordinates are device coordinates.</para>
/// <para>Examples</para>
/// <para>For an example, see "Drawing Lines with the Mouse" in Using Mouse Input.</para>
/// </remarks>
// 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);
/// <summary>Retrieves the screen auto-rotation preferences for the current process.</summary>
/// <param name="pOrientation">
/// Pointer to a location in memory that will receive the current orientation preference setting for the calling process.
/// </param>
/// <returns>TRUE if the method succeeds, otherwise FALSE.</returns>
// 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);
/// <summary>
/// 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.
/// </summary>
/// <param name="hWndFrom">
/// 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.
/// </param>
/// <param name="hWndTo">
/// 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.
/// </param>
/// <param name="lpPoints">
/// 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.
/// </param>
/// <param name="cPoints">The number of POINT structures in the array pointed to by the lpPoints parameter.</param>
/// <returns>
/// 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.
/// <para>
/// 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.
/// </para>
/// </returns>
[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);
/// <summary>
/// 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.
/// </summary>
/// <param name="hWndFrom">
/// 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.
/// </param>
/// <param name="hWndTo">
/// 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.
/// </param>
/// <param name="lpPoints">
/// 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.
/// </param>
/// <param name="cPoints">The number of POINT structures in the array pointed to by the lpPoints parameter.</param>
/// <returns>
/// 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.
/// <para>
/// 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.
/// </para>
/// </returns>
[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);
/// <summary>
/// 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.
/// </summary>
/// <param name="hWndFrom">
/// 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.
/// </param>
/// <param name="hWndTo">
/// 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.
/// </param>
/// <param name="lpPoints">
/// 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.
/// </param>
/// <param name="cPoints">The number of POINT structures in the array pointed to by the lpPoints parameter.</param>
/// <returns>
/// 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.
/// <para>
/// 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.
/// </para>
/// </returns>
[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);
/// <summary>The ScreenToClient function converts the screen coordinates of a specified point on the screen to client-area coordinates.</summary>
/// <param name="hWnd">A handle to the window whose client area will be used for the conversion.</param>
/// <param name="lpPoint">A pointer to a POINT structure that specifies the screen coordinates to be converted.</param>
/// <returns>
/// 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.
/// </returns>
[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);
/// <summary>Sets the orientation preferences of the display.</summary>
/// <param name="orientation">The orientation.</param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If this function set the orientation preferences, the return value is nonzero.</para>
/// <para>If the orientation preferences weren't set, the return value is zero.</para>
/// </returns>
/// <remarks>
/// An app can remove the orientation preferences of the display after it sets them by passing <c>ORIENTATION_PREFERENCE_NONE</c> to
/// <c>SetDisplayAutoRotationPreferences</c>. An app can change the orientation preferences of the display by passing a different
/// combination of <c>ORIENTATION_PREFERENCE</c>-typed values to <c>SetDisplayAutoRotationPreferences</c>.
/// </remarks>
// 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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,307 @@
using System.Drawing;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32_Gdi
{
/// <summary>The <c>CopyRect</c> function copies the coordinates of one rectangle to another.</summary>
/// <param name="lprcDst">Pointer to the RECT structure that receives the logical coordinates of the source rectangle.</param>
/// <param name="lprcSrc">Pointer to the RECT structure whose coordinates are to be copied in logical units.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>
/// The <c>EqualRect</c> function determines whether the two specified rectangles are equal by comparing the coordinates of their
/// upper-left and lower-right corners.
/// </summary>
/// <param name="lprc1">Pointer to a RECT structure that contains the logical coordinates of the first rectangle.</param>
/// <param name="lprc2">Pointer to a RECT structure that contains the logical coordinates of the second rectangle.</param>
/// <returns>
/// <para>If the two rectangles are identical, the return value is nonzero.</para>
/// <para>If the two rectangles are not identical, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>The <c>EqualRect</c> function does not treat empty rectangles as equal if their coordinates are different.</para>
/// <para>
/// 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.
/// </para>
/// </remarks>
// 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);
/// <summary>
/// The <c>InflateRect</c> function increases or decreases the width and height of the specified rectangle. The <c>InflateRect</c>
/// 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.
/// </summary>
/// <param name="lprc">A pointer to the RECT structure that increases or decreases in size.</param>
/// <param name="dx">The amount to increase or decrease the rectangle width. This parameter must be negative to decrease the width.</param>
/// <param name="dy">The amount to increase or decrease the rectangle height. This parameter must be negative to decrease the height.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// 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.
/// </remarks>
// 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);
/// <summary>
/// The <c>IntersectRect</c> 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.
/// </summary>
/// <param name="lprcDst">
/// 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 <c>NULL</c>.
/// </param>
/// <param name="lprcSrc1">A pointer to the RECT structure that contains the first source rectangle.</param>
/// <param name="lprcSrc2">A pointer to the RECT structure that contains the second source rectangle.</param>
/// <returns>
/// <para>If the rectangles intersect, the return value is nonzero.</para>
/// <para>If the rectangles do not intersect, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>
/// The <c>IsRectEmpty</c> 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.
/// </summary>
/// <param name="lprc">Pointer to a RECT structure that contains the logical coordinates of the rectangle.</param>
/// <returns>
/// <para>If the rectangle is empty, the return value is nonzero.</para>
/// <para>If the rectangle is not empty, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>The <c>OffsetRect</c> function moves the specified rectangle by the specified offsets.</summary>
/// <param name="lprc">Pointer to a RECT structure that contains the logical coordinates of the rectangle to be moved.</param>
/// <param name="dx">
/// Specifies the amount to move the rectangle left or right. This parameter must be a negative value to move the rectangle to the left.
/// </param>
/// <param name="dy">
/// Specifies the amount to move the rectangle up or down. This parameter must be a negative value to move the rectangle up.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>
/// The <c>PtInRect</c> 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.
/// </summary>
/// <param name="lprc">A pointer to a RECT structure that contains the specified rectangle.</param>
/// <param name="pt">A POINT structure that contains the specified point.</param>
/// <returns>
/// <para>If the specified point lies within the rectangle, the return value is nonzero.</para>
/// <para>If the specified point does not lie within the rectangle, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// The rectangle must be normalized before <c>PtInRect</c> 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.
/// </para>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>
/// The <c>SetRect</c> 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 <c>RECT</c> structure.
/// </summary>
/// <param name="lprc">Pointer to the RECT structure that contains the rectangle to be set.</param>
/// <param name="xLeft">Specifies the x-coordinate of the rectangle's upper-left corner.</param>
/// <param name="yTop">Specifies the y-coordinate of the rectangle's upper-left corner.</param>
/// <param name="xRight">Specifies the x-coordinate of the rectangle's lower-right corner.</param>
/// <param name="yBottom">Specifies the y-coordinate of the rectangle's lower-right corner.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>The <c>SetRectEmpty</c> function creates an empty rectangle in which all coordinates are set to zero.</summary>
/// <param name="lprc">Pointer to the RECT structure that contains the coordinates of the rectangle.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Rectangles.</para>
/// </remarks>
// 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);
/// <summary>
/// The <c>SubtractRect</c> function determines the coordinates of a rectangle formed by subtracting one rectangle from another.
/// </summary>
/// <param name="lprcDst">
/// 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.
/// </param>
/// <param name="lprcSrc1">A pointer to a RECT structure from which the function subtracts the rectangle pointed to by lprcSrc2.</param>
/// <param name="lprcSrc2">A pointer to a RECT structure that the function subtracts from the rectangle pointed to by lprcSrc1.</param>
/// <returns>
/// <para>If the resulting rectangle is empty, the return value is zero.</para>
/// <para>If the resulting rectangle is not empty, the return value is nonzero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>
/// 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.
/// </para>
/// </remarks>
// 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);
/// <summary>
/// The <c>UnionRect</c> function creates the union of two rectangles. The union is the smallest rectangle that contains both source rectangles.
/// </summary>
/// <param name="lprcDst">
/// A pointer to the RECT structure that will receive a rectangle containing the rectangles pointed to by the lprcSrc1 and lprcSrc2 parameters.
/// </param>
/// <param name="lprcSrc1">A pointer to the RECT structure that contains the first source rectangle.</param>
/// <param name="lprcSrc2">A pointer to the RECT structure that contains the second source rectangle.</param>
/// <returns>
/// <para>If the specified structure contains a nonempty rectangle, the return value is nonzero.</para>
/// <para>If the specified structure does not contain a nonempty rectangle, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// <para>
/// 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.
/// </para>
/// </remarks>
// 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);
}
}