From 5848e17bed013dce5703921db67f8759d0c4b5dd Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 5 Feb 2019 14:15:17 -0700 Subject: [PATCH] Added multiple new GDI related functions --- PInvoke/User32.Gdi/WinUser.Gdi.cs | 1996 ++++++++++++++++++++++++++++++------- 1 file changed, 1651 insertions(+), 345 deletions(-) diff --git a/PInvoke/User32.Gdi/WinUser.Gdi.cs b/PInvoke/User32.Gdi/WinUser.Gdi.cs index 8b9bcfae..ac87a41a 100644 --- a/PInvoke/User32.Gdi/WinUser.Gdi.cs +++ b/PInvoke/User32.Gdi/WinUser.Gdi.cs @@ -12,112 +12,55 @@ namespace Vanara.PInvoke { public const int OCM_NOTIFY = 0x204E; // WM_NOTIFY + WM_REFLECT - /// Flags used by the method. - [PInvokeData("WinUser.h")] + /// Flags used by . + [PInvokeData("winuser.h", MSDNShortId = "208bf1cc-c03c-4d03-92e4-32fcf856b4d8")] [Flags] - public enum BorderFlags : uint + public enum ChangeDisplaySettingsFlags { - /// 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 graphics mode for the current screen will be changed dynamically. + CDS_DEFAULT = 0, /// - /// The rectangle pointed to by the pDestRect parameter is shrunk to exclude the edges that were drawn; otherwise the rectangle - /// does not change. + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. + /// The mode information is stored in the USER profile. /// - BF_ADJUST = 0x2000, + CDS_UPDATEREGISTRY = 0x00000001, - /// Flat border. - BF_FLAT = 0x4000, + /// The system tests if the requested graphics mode could be set. + CDS_TEST = 0x00000002, - /// One-dimensional border. - BF_MONO = 0x8000, - } + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + CDS_FULLSCREEN = 0x00000004, - /// Styles used by the method. - [PInvokeData("WinUser.h")] - [Flags] - public enum BorderStyles3D : uint - { - /// Raised outer edge - BDR_RAISEDOUTER = 0x0001, + /// + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. + /// + CDS_GLOBAL = 0x00000008, - /// Sunken outer edge - BDR_SUNKENOUTER = 0x0002, + /// This device will become the primary device. + CDS_SET_PRIMARY = 0x00000010, - /// Raised inner edge - BDR_RAISEDINNER = 0x0004, + /// When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure. + CDS_VIDEOPARAMETERS = 0x00000020, - /// Sunken inner edge - BDR_SUNKENINNER = 0x0008, + /// Enables settings changes to unsafe graphics modes. + CDS_ENABLE_UNSAFE_MODES = 0x00000100, - /// Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER - BDR_OUTER = (BDR_RAISEDOUTER | BDR_SUNKENOUTER), + /// Disables settings changes to unsafe graphics modes. + CDS_DISABLE_UNSAFE_MODES = 0x00000200, - /// Combination of BDR_RAISEDINNER and BDR_SUNKENINNER - BDR_INNER = (BDR_RAISEDINNER | BDR_SUNKENINNER), + /// The settings should be changed, even if the requested settings are the same as the current settings. + CDS_RESET = 0x40000000, - /// Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER - BDR_RAISED = (BDR_RAISEDOUTER | BDR_RAISEDINNER), + /// Undocumented + CDS_RESET_EX = 0x20000000, - /// 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), + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// + CDS_NORESET = 0x10000000, } [Flags] @@ -158,6 +101,57 @@ namespace Vanara.PInvoke LR_MONOCHROME = 0x00000001, } + /// Flags used by . + [PInvokeData("winuser.h", MSDNShortId = "590cf928-0ad6-43f8-97e9-1dafbcfa9f49")] + [Flags] + public enum DCX + { + /// Returns a DC that corresponds to the window rectangle rather than the client rectangle. + DCX_WINDOW = 0x00000001, + + /// Returns a DC from the cache, rather than the OWNDC or CLASSDC window. Essentially overrides CS_OWNDC and CS_CLASSDC. + DCX_CACHE = 0x00000002, + + /// This flag is ignored. + DCX_NORESETATTRS = 0x00000004, + + /// Excludes the visible regions of all child windows below the window identified by hWnd. + DCX_CLIPCHILDREN = 0x00000008, + + /// Excludes the visible regions of all sibling windows above the window identified by hWnd. + DCX_CLIPSIBLINGS = 0x00000010, + + /// + /// Uses the visible region of the parent window. The parent's WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored. The origin + /// is set to the upper-left corner of the window identified by hWnd. + /// + DCX_PARENTCLIP = 0x00000020, + + /// The clipping region identified by hrgnClip is excluded from the visible region of the returned DC. + DCX_EXCLUDERGN = 0x00000040, + + /// The clipping region identified by hrgnClip is intersected with the visible region of the returned DC. + DCX_INTERSECTRGN = 0x00000080, + + /// Returns a region that excludes the window's update region. + DCX_EXCLUDEUPDATE = 0x00000100, + + /// Returns a region that includes the window's update region. + DCX_INTERSECTUPDATE = 0x00000200, + + /// + /// Allows drawing even if there is a LockWindowUpdate call in effect that would otherwise exclude this window. Used for drawing + /// during tracking. + /// + DCX_LOCKWINDOWUPDATE = 0x00000400, + + /// + /// When specified with DCX_INTERSECTUPDATE, causes the device context to be completely validated. + /// Using this function with both DCX_INTERSECTUPDATE and DCX_VALIDATE is identical to using the BeginPaint function. + /// + DCX_VALIDATE = 0x00200000, + } + /// Values to use a return codes when handling the WM_HCHITTEST message. public enum HitTestValues : short { @@ -289,171 +283,1211 @@ namespace Vanara.PInvoke DWLP_DLGPROC = 0x4 } - /// 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. + /// The ChangeDisplaySettings function changes the settings of the default display device to the specified graphics mode. + /// + /// To change the settings of a specified display device, use the ChangeDisplaySettingsEx function. + /// + /// Note Apps that you design to target Windows 8 and later can no longer query or set display modes that are less than 32 + /// bits per pixel (bpp); these operations will fail. These apps have a compatibility manifest that targets Windows 8. Windows 8 + /// still supports 8-bit and 16-bit color modes for desktop apps that were built without a Windows 8 manifest; Windows 8 emulates + /// these modes but still runs in 32-bit color mode. + /// + /// + /// + /// + /// A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in + /// the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags + /// parameter is the easiest way to return to the default mode after a dynamic mode change. /// /// + /// The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure. The + /// dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data + /// following the DEVMODE structure. In addition, you can use any or all of the following members of the DEVMODE structure. + /// /// /// - /// Value + /// Member /// Meaning /// /// - /// BDR_RAISEDINNER - /// Raised inner edge. + /// dmBitsPerPel + /// Bits per pixel /// /// - /// BDR_SUNKENINNER - /// Sunken inner edge. + /// dmPelsWidth + /// Pixel width + /// + /// + /// dmPelsHeight + /// Pixel height + /// + /// + /// dmDisplayFlags + /// Mode flags + /// + /// + /// dmDisplayFrequency + /// Mode frequency + /// + /// + /// dmPosition + /// Position of the device in a multi-monitor configuration. /// /// - /// - /// 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. - /// - /// + /// In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the + /// dmFields member to change the display setting. /// /// - /// - /// The type of border. This parameter can be a combination of the following values. - /// + /// + /// Indicates how the graphics mode should be changed. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// - /// BF_ADJUST + /// 0 + /// The graphics mode for the current screen will be changed dynamically. + /// + /// + /// CDS_FULLSCREEN + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + /// + /// + /// CDS_GLOBAL /// - /// 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. + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. /// /// /// - /// BF_BOTTOM - /// Bottom of border rectangle. + /// CDS_NORESET + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// /// /// - /// BF_BOTTOMLEFT - /// Bottom and left side of border rectangle. + /// CDS_RESET + /// The settings should be changed, even if the requested settings are the same as the current settings. /// /// - /// BF_BOTTOMRIGHT - /// Bottom and right side of border rectangle. + /// CDS_SET_PRIMARY + /// This device will become the primary device. /// /// - /// BF_DIAGONAL - /// Diagonal border. + /// CDS_TEST + /// The system tests if the requested graphics mode could be set. /// /// - /// 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. + /// CDS_UPDATEREGISTRY + /// + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The + /// mode information is stored in the USER profile. + /// /// /// + /// + /// Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to + /// change to that graphics mode. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the + /// registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information + /// is stored in the registry and DISP_CHANGE_RESTART is returned. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and + /// DISP_CHANGE_NOTUPDATED is returned. /// /// /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. + /// The ChangeDisplaySettings function returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// DISP_CHANGE_SUCCESSFUL + /// The settings change was successful. + /// + /// + /// DISP_CHANGE_BADDUALVIEW + /// The settings change was unsuccessful because the system is DualView capable. + /// + /// + /// DISP_CHANGE_BADFLAGS + /// An invalid set of flags was passed in. + /// + /// + /// DISP_CHANGE_BADMODE + /// The graphics mode is not supported. + /// + /// + /// DISP_CHANGE_BADPARAM + /// An invalid parameter was passed in. This can include an invalid flag or combination of flags. + /// + /// + /// DISP_CHANGE_FAILED + /// The display driver failed the specified graphics mode. + /// + /// + /// DISP_CHANGE_NOTUPDATED + /// Unable to write settings to the registry. + /// + /// + /// DISP_CHANGE_RESTART + /// The computer must be restarted for the graphics mode to work. + /// + /// /// - // 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); + /// + /// + /// To ensure that the DEVMODE structure passed to ChangeDisplaySettings is valid and contains only values supported by the + /// display driver, use the DEVMODE returned by the EnumDisplaySettings function. + /// + /// + /// When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following + /// message parameters. + /// + /// + /// + /// Parameters + /// Meaning + /// + /// + /// wParam + /// New bits per pixel + /// + /// + /// LOWORD(lParam) + /// New pixel width + /// + /// + /// HIWORD(lParam) + /// New pixel height + /// + /// + /// 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-changedisplaysettingsa LONG ChangeDisplaySettingsA( + // DEVMODEA *lpDevMode, DWORD dwFlags ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "208bf1cc-c03c-4d03-92e4-32fcf856b4d8")] + public static extern int ChangeDisplaySettings(in DEVMODE lpDevMode, ChangeDisplaySettingsFlags dwFlags); + + /// + /// + /// The ChangeDisplaySettings function changes the settings of the default display device to the specified graphics mode. + /// + /// To change the settings of a specified display device, use the ChangeDisplaySettingsEx function. + /// + /// Note Apps that you design to target Windows 8 and later can no longer query or set display modes that are less than 32 + /// bits per pixel (bpp); these operations will fail. These apps have a compatibility manifest that targets Windows 8. Windows 8 + /// still supports 8-bit and 16-bit color modes for desktop apps that were built without a Windows 8 manifest; Windows 8 emulates + /// these modes but still runs in 32-bit color mode. + /// + /// + /// + /// + /// A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in + /// the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags + /// parameter is the easiest way to return to the default mode after a dynamic mode change. + /// + /// + /// The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure. The + /// dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data + /// following the DEVMODE structure. In addition, you can use any or all of the following members of the DEVMODE structure. + /// + /// + /// + /// Member + /// Meaning + /// + /// + /// dmBitsPerPel + /// Bits per pixel + /// + /// + /// dmPelsWidth + /// Pixel width + /// + /// + /// dmPelsHeight + /// Pixel height + /// + /// + /// dmDisplayFlags + /// Mode flags + /// + /// + /// dmDisplayFrequency + /// Mode frequency + /// + /// + /// dmPosition + /// Position of the device in a multi-monitor configuration. + /// + /// + /// + /// In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the + /// dmFields member to change the display setting. + /// + /// + /// + /// Indicates how the graphics mode should be changed. This parameter can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// 0 + /// The graphics mode for the current screen will be changed dynamically. + /// + /// + /// CDS_FULLSCREEN + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + /// + /// + /// CDS_GLOBAL + /// + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_NORESET + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_RESET + /// The settings should be changed, even if the requested settings are the same as the current settings. + /// + /// + /// CDS_SET_PRIMARY + /// This device will become the primary device. + /// + /// + /// CDS_TEST + /// The system tests if the requested graphics mode could be set. + /// + /// + /// CDS_UPDATEREGISTRY + /// + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The + /// mode information is stored in the USER profile. + /// + /// + /// + /// + /// Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to + /// change to that graphics mode. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the + /// registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information + /// is stored in the registry and DISP_CHANGE_RESTART is returned. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and + /// DISP_CHANGE_NOTUPDATED is returned. + /// + /// + /// + /// The ChangeDisplaySettings function returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// DISP_CHANGE_SUCCESSFUL + /// The settings change was successful. + /// + /// + /// DISP_CHANGE_BADDUALVIEW + /// The settings change was unsuccessful because the system is DualView capable. + /// + /// + /// DISP_CHANGE_BADFLAGS + /// An invalid set of flags was passed in. + /// + /// + /// DISP_CHANGE_BADMODE + /// The graphics mode is not supported. + /// + /// + /// DISP_CHANGE_BADPARAM + /// An invalid parameter was passed in. This can include an invalid flag or combination of flags. + /// + /// + /// DISP_CHANGE_FAILED + /// The display driver failed the specified graphics mode. + /// + /// + /// DISP_CHANGE_NOTUPDATED + /// Unable to write settings to the registry. + /// + /// + /// DISP_CHANGE_RESTART + /// The computer must be restarted for the graphics mode to work. + /// + /// + /// + /// + /// + /// To ensure that the DEVMODE structure passed to ChangeDisplaySettings is valid and contains only values supported by the + /// display driver, use the DEVMODE returned by the EnumDisplaySettings function. + /// + /// + /// When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following + /// message parameters. + /// + /// + /// + /// Parameters + /// Meaning + /// + /// + /// wParam + /// New bits per pixel + /// + /// + /// LOWORD(lParam) + /// New pixel width + /// + /// + /// HIWORD(lParam) + /// New pixel height + /// + /// + /// 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-changedisplaysettingsa LONG ChangeDisplaySettingsA( + // DEVMODEA *lpDevMode, DWORD dwFlags ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "208bf1cc-c03c-4d03-92e4-32fcf856b4d8")] + public static extern int ChangeDisplaySettings([Optional] IntPtr lpDevMode, ChangeDisplaySettingsFlags dwFlags); + + /// + /// + /// The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode. + /// + /// + /// Note Apps that you design to target Windows 8 and later can no longer query or set display modes that are less than 32 + /// bits per pixel (bpp); these operations will fail. These apps have a compatibility manifest that targets Windows 8. Windows 8 + /// still supports 8-bit and 16-bit color modes for desktop apps that were built without a Windows 8 manifest; Windows 8 emulates + /// these modes but still runs in 32-bit color mode. + /// + /// + /// + /// + /// A pointer to a null-terminated string that specifies the display device whose graphics mode will change. Only display device + /// names as returned by EnumDisplayDevices are valid. See EnumDisplayDevices for further information on the names associated + /// with these display devices. + /// + /// + /// The lpszDeviceName parameter can be NULL. A NULL value specifies the default display device. The default device can + /// be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag. + /// + /// + /// + /// + /// A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in + /// the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags + /// parameter is the easiest way to return to the default mode after a dynamic mode change. + /// + /// + /// The dmSize member must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member + /// must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, + /// you can use any of the following members of the DEVMODE structure. + /// + /// + /// + /// Member + /// Meaning + /// + /// + /// dmBitsPerPel + /// Bits per pixel + /// + /// + /// dmPelsWidth + /// Pixel width + /// + /// + /// dmPelsHeight + /// Pixel height + /// + /// + /// dmDisplayFlags + /// Mode flags + /// + /// + /// dmDisplayFrequency + /// Mode frequency + /// + /// + /// dmPosition + /// Position of the device in a multi-monitor configuration. + /// + /// + /// + /// In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the + /// dmFields member to change the display settings. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// DM_BITSPERPEL + /// Use the dmBitsPerPel value. + /// + /// + /// DM_PELSWIDTH + /// Use the dmPelsWidth value. + /// + /// + /// DM_PELSHEIGHT + /// Use the dmPelsHeight value. + /// + /// + /// DM_DISPLAYFLAGS + /// Use the dmDisplayFlags value. + /// + /// + /// DM_DISPLAYFREQUENCY + /// Use the dmDisplayFrequency value. + /// + /// + /// DM_POSITION + /// Use the dmPosition value. + /// + /// + /// + /// Reserved; must be NULL. + /// + /// Indicates how the graphics mode should be changed. This parameter can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// 0 + /// The graphics mode for the current screen will be changed dynamically. + /// + /// + /// CDS_FULLSCREEN + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + /// + /// + /// CDS_GLOBAL + /// + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_NORESET + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_RESET + /// The settings should be changed, even if the requested settings are the same as the current settings. + /// + /// + /// CDS_SET_PRIMARY + /// This device will become the primary device. + /// + /// + /// CDS_TEST + /// The system tests if the requested graphics mode could be set. + /// + /// + /// CDS_UPDATEREGISTRY + /// + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The + /// mode information is stored in the USER profile. + /// + /// + /// + /// CDS_VIDEOPARAMETERS + /// When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure. + /// + /// + /// CDS_ENABLE_UNSAFE_MODES + /// Enables settings changes to unsafe graphics modes. + /// + /// + /// CDS_DISABLE_UNSAFE_MODES + /// Disables settings changes to unsafe graphics modes. + /// + /// + /// + /// Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to + /// change to them. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the + /// registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information + /// is stored in the registry and DISP_CHANGE_RESTART is returned. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and + /// DISP_CHANGE_NOTUPDATED is returned. + /// + /// + /// + /// If dwFlags is CDS_VIDEOPARAMETERS, lParam is a pointer to a VIDEOPARAMETERS structure. Otherwise lParam must be NULL. + /// + /// + /// The ChangeDisplaySettingsEx function returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// DISP_CHANGE_SUCCESSFUL + /// The settings change was successful. + /// + /// + /// DISP_CHANGE_BADDUALVIEW + /// The settings change was unsuccessful because the system is DualView capable. + /// + /// + /// DISP_CHANGE_BADFLAGS + /// An invalid set of flags was passed in. + /// + /// + /// DISP_CHANGE_BADMODE + /// The graphics mode is not supported. + /// + /// + /// DISP_CHANGE_BADPARAM + /// An invalid parameter was passed in. This can include an invalid flag or combination of flags. + /// + /// + /// DISP_CHANGE_FAILED + /// The display driver failed the specified graphics mode. + /// + /// + /// DISP_CHANGE_NOTUPDATED + /// Unable to write settings to the registry. + /// + /// + /// DISP_CHANGE_RESTART + /// The computer must be restarted for the graphics mode to work. + /// + /// + /// + /// + /// + /// To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the + /// display driver, use the DEVMODE returned by the EnumDisplaySettings function. + /// + /// + /// When adding a display monitor to a multiple-monitor system programmatically, set DEVMODE.dmFields to DM_POSITION and + /// specify a position (in DEVMODE.dmPosition) for the monitor you are adding that is adjacent to at least one pixel of the + /// display area of an existing monitor. To detach the monitor, set DEVMODE.dmFields to DM_POSITION but set + /// DEVMODE.dmPelsWidth and DEVMODE.dmPelsHeight to zero. For more information, see Multiple Display Monitors. + /// + /// + /// When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following + /// message parameters. + /// + /// + /// + /// Parameters + /// Meaning + /// + /// + /// wParam + /// New bits per pixel + /// + /// + /// LOWORD(lParam) + /// New pixel width + /// + /// + /// HIWORD(lParam) + /// New pixel height + /// + /// + /// + /// To change the settings for more than one display at the same time, first call ChangeDisplaySettingsEx for each device + /// individually to update the registry without applying the changes. Then call ChangeDisplaySettingsEx once more, with a + /// NULL device, to apply the changes. For example, to change the settings for two displays, do the following: + /// + /// 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-changedisplaysettingsexa LONG ChangeDisplaySettingsExA( + // LPCSTR lpszDeviceName, DEVMODEA *lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "1448e04c-1452-4eab-bda4-4d249cb67a24")] + public static extern int ChangeDisplaySettingsEx([Optional] string lpszDeviceName, in DEVMODE lpDevMode, [Optional] HWND hwnd, [Optional] ChangeDisplaySettingsFlags dwflags, [Optional] IntPtr lParam); + + /// + /// + /// The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode. + /// + /// + /// Note Apps that you design to target Windows 8 and later can no longer query or set display modes that are less than 32 + /// bits per pixel (bpp); these operations will fail. These apps have a compatibility manifest that targets Windows 8. Windows 8 + /// still supports 8-bit and 16-bit color modes for desktop apps that were built without a Windows 8 manifest; Windows 8 emulates + /// these modes but still runs in 32-bit color mode. + /// + /// + /// + /// + /// A pointer to a null-terminated string that specifies the display device whose graphics mode will change. Only display device + /// names as returned by EnumDisplayDevices are valid. See EnumDisplayDevices for further information on the names associated + /// with these display devices. + /// + /// + /// The lpszDeviceName parameter can be NULL. A NULL value specifies the default display device. The default device can + /// be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag. + /// + /// + /// + /// + /// A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in + /// the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags + /// parameter is the easiest way to return to the default mode after a dynamic mode change. + /// + /// + /// The dmSize member must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member + /// must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, + /// you can use any of the following members of the DEVMODE structure. + /// + /// + /// + /// Member + /// Meaning + /// + /// + /// dmBitsPerPel + /// Bits per pixel + /// + /// + /// dmPelsWidth + /// Pixel width + /// + /// + /// dmPelsHeight + /// Pixel height + /// + /// + /// dmDisplayFlags + /// Mode flags + /// + /// + /// dmDisplayFrequency + /// Mode frequency + /// + /// + /// dmPosition + /// Position of the device in a multi-monitor configuration. + /// + /// + /// + /// In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the + /// dmFields member to change the display settings. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// DM_BITSPERPEL + /// Use the dmBitsPerPel value. + /// + /// + /// DM_PELSWIDTH + /// Use the dmPelsWidth value. + /// + /// + /// DM_PELSHEIGHT + /// Use the dmPelsHeight value. + /// + /// + /// DM_DISPLAYFLAGS + /// Use the dmDisplayFlags value. + /// + /// + /// DM_DISPLAYFREQUENCY + /// Use the dmDisplayFrequency value. + /// + /// + /// DM_POSITION + /// Use the dmPosition value. + /// + /// + /// + /// Reserved; must be NULL. + /// + /// Indicates how the graphics mode should be changed. This parameter can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// 0 + /// The graphics mode for the current screen will be changed dynamically. + /// + /// + /// CDS_FULLSCREEN + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + /// + /// + /// CDS_GLOBAL + /// + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_NORESET + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_RESET + /// The settings should be changed, even if the requested settings are the same as the current settings. + /// + /// + /// CDS_SET_PRIMARY + /// This device will become the primary device. + /// + /// + /// CDS_TEST + /// The system tests if the requested graphics mode could be set. + /// + /// + /// CDS_UPDATEREGISTRY + /// + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The + /// mode information is stored in the USER profile. + /// + /// + /// + /// CDS_VIDEOPARAMETERS + /// When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure. + /// + /// + /// CDS_ENABLE_UNSAFE_MODES + /// Enables settings changes to unsafe graphics modes. + /// + /// + /// CDS_DISABLE_UNSAFE_MODES + /// Disables settings changes to unsafe graphics modes. + /// + /// + /// + /// Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to + /// change to them. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the + /// registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information + /// is stored in the registry and DISP_CHANGE_RESTART is returned. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and + /// DISP_CHANGE_NOTUPDATED is returned. + /// + /// + /// + /// If dwFlags is CDS_VIDEOPARAMETERS, lParam is a pointer to a VIDEOPARAMETERS structure. Otherwise lParam must be NULL. + /// + /// + /// The ChangeDisplaySettingsEx function returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// DISP_CHANGE_SUCCESSFUL + /// The settings change was successful. + /// + /// + /// DISP_CHANGE_BADDUALVIEW + /// The settings change was unsuccessful because the system is DualView capable. + /// + /// + /// DISP_CHANGE_BADFLAGS + /// An invalid set of flags was passed in. + /// + /// + /// DISP_CHANGE_BADMODE + /// The graphics mode is not supported. + /// + /// + /// DISP_CHANGE_BADPARAM + /// An invalid parameter was passed in. This can include an invalid flag or combination of flags. + /// + /// + /// DISP_CHANGE_FAILED + /// The display driver failed the specified graphics mode. + /// + /// + /// DISP_CHANGE_NOTUPDATED + /// Unable to write settings to the registry. + /// + /// + /// DISP_CHANGE_RESTART + /// The computer must be restarted for the graphics mode to work. + /// + /// + /// + /// + /// + /// To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the + /// display driver, use the DEVMODE returned by the EnumDisplaySettings function. + /// + /// + /// When adding a display monitor to a multiple-monitor system programmatically, set DEVMODE.dmFields to DM_POSITION and + /// specify a position (in DEVMODE.dmPosition) for the monitor you are adding that is adjacent to at least one pixel of the + /// display area of an existing monitor. To detach the monitor, set DEVMODE.dmFields to DM_POSITION but set + /// DEVMODE.dmPelsWidth and DEVMODE.dmPelsHeight to zero. For more information, see Multiple Display Monitors. + /// + /// + /// When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following + /// message parameters. + /// + /// + /// + /// Parameters + /// Meaning + /// + /// + /// wParam + /// New bits per pixel + /// + /// + /// LOWORD(lParam) + /// New pixel width + /// + /// + /// HIWORD(lParam) + /// New pixel height + /// + /// + /// + /// To change the settings for more than one display at the same time, first call ChangeDisplaySettingsEx for each device + /// individually to update the registry without applying the changes. Then call ChangeDisplaySettingsEx once more, with a + /// NULL device, to apply the changes. For example, to change the settings for two displays, do the following: + /// + /// 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-changedisplaysettingsexa LONG ChangeDisplaySettingsExA( + // LPCSTR lpszDeviceName, DEVMODEA *lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "1448e04c-1452-4eab-bda4-4d249cb67a24")] + public static extern int ChangeDisplaySettingsEx([Optional] string lpszDeviceName, [Optional] IntPtr lpDevMode, [Optional] HWND hwnd, [Optional] ChangeDisplaySettingsFlags dwflags, [Optional] IntPtr lParam); + + /// + /// + /// The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode. + /// + /// + /// Note Apps that you design to target Windows 8 and later can no longer query or set display modes that are less than 32 + /// bits per pixel (bpp); these operations will fail. These apps have a compatibility manifest that targets Windows 8. Windows 8 + /// still supports 8-bit and 16-bit color modes for desktop apps that were built without a Windows 8 manifest; Windows 8 emulates + /// these modes but still runs in 32-bit color mode. + /// + /// + /// + /// + /// A pointer to a null-terminated string that specifies the display device whose graphics mode will change. Only display device + /// names as returned by EnumDisplayDevices are valid. See EnumDisplayDevices for further information on the names associated + /// with these display devices. + /// + /// + /// The lpszDeviceName parameter can be NULL. A NULL value specifies the default display device. The default device can + /// be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag. + /// + /// + /// + /// + /// A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in + /// the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags + /// parameter is the easiest way to return to the default mode after a dynamic mode change. + /// + /// + /// The dmSize member must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member + /// must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, + /// you can use any of the following members of the DEVMODE structure. + /// + /// + /// + /// Member + /// Meaning + /// + /// + /// dmBitsPerPel + /// Bits per pixel + /// + /// + /// dmPelsWidth + /// Pixel width + /// + /// + /// dmPelsHeight + /// Pixel height + /// + /// + /// dmDisplayFlags + /// Mode flags + /// + /// + /// dmDisplayFrequency + /// Mode frequency + /// + /// + /// dmPosition + /// Position of the device in a multi-monitor configuration. + /// + /// + /// + /// In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the + /// dmFields member to change the display settings. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// DM_BITSPERPEL + /// Use the dmBitsPerPel value. + /// + /// + /// DM_PELSWIDTH + /// Use the dmPelsWidth value. + /// + /// + /// DM_PELSHEIGHT + /// Use the dmPelsHeight value. + /// + /// + /// DM_DISPLAYFLAGS + /// Use the dmDisplayFlags value. + /// + /// + /// DM_DISPLAYFREQUENCY + /// Use the dmDisplayFrequency value. + /// + /// + /// DM_POSITION + /// Use the dmPosition value. + /// + /// + /// + /// Reserved; must be NULL. + /// + /// Indicates how the graphics mode should be changed. This parameter can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// 0 + /// The graphics mode for the current screen will be changed dynamically. + /// + /// + /// CDS_FULLSCREEN + /// The mode is temporary in nature. If you change to and from another desktop, this mode will not be reset. + /// + /// + /// CDS_GLOBAL + /// + /// The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the + /// settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_NORESET + /// + /// The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the + /// CDS_UPDATEREGISTRY flag. + /// + /// + /// + /// CDS_RESET + /// The settings should be changed, even if the requested settings are the same as the current settings. + /// + /// + /// CDS_SET_PRIMARY + /// This device will become the primary device. + /// + /// + /// CDS_TEST + /// The system tests if the requested graphics mode could be set. + /// + /// + /// CDS_UPDATEREGISTRY + /// + /// The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The + /// mode information is stored in the USER profile. + /// + /// + /// + /// CDS_VIDEOPARAMETERS + /// When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure. + /// + /// + /// CDS_ENABLE_UNSAFE_MODES + /// Enables settings changes to unsafe graphics modes. + /// + /// + /// CDS_DISABLE_UNSAFE_MODES + /// Disables settings changes to unsafe graphics modes. + /// + /// + /// + /// Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to + /// change to them. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the + /// registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information + /// is stored in the registry and DISP_CHANGE_RESTART is returned. + /// + /// + /// If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and + /// DISP_CHANGE_NOTUPDATED is returned. + /// + /// + /// + /// If dwFlags is CDS_VIDEOPARAMETERS, lParam is a pointer to a VIDEOPARAMETERS structure. Otherwise lParam must be NULL. + /// + /// + /// The ChangeDisplaySettingsEx function returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// DISP_CHANGE_SUCCESSFUL + /// The settings change was successful. + /// + /// + /// DISP_CHANGE_BADDUALVIEW + /// The settings change was unsuccessful because the system is DualView capable. + /// + /// + /// DISP_CHANGE_BADFLAGS + /// An invalid set of flags was passed in. + /// + /// + /// DISP_CHANGE_BADMODE + /// The graphics mode is not supported. + /// + /// + /// DISP_CHANGE_BADPARAM + /// An invalid parameter was passed in. This can include an invalid flag or combination of flags. + /// + /// + /// DISP_CHANGE_FAILED + /// The display driver failed the specified graphics mode. + /// + /// + /// DISP_CHANGE_NOTUPDATED + /// Unable to write settings to the registry. + /// + /// + /// DISP_CHANGE_RESTART + /// The computer must be restarted for the graphics mode to work. + /// + /// + /// + /// + /// + /// To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the + /// display driver, use the DEVMODE returned by the EnumDisplaySettings function. + /// + /// + /// When adding a display monitor to a multiple-monitor system programmatically, set DEVMODE.dmFields to DM_POSITION and + /// specify a position (in DEVMODE.dmPosition) for the monitor you are adding that is adjacent to at least one pixel of the + /// display area of an existing monitor. To detach the monitor, set DEVMODE.dmFields to DM_POSITION but set + /// DEVMODE.dmPelsWidth and DEVMODE.dmPelsHeight to zero. For more information, see Multiple Display Monitors. + /// + /// + /// When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following + /// message parameters. + /// + /// + /// + /// Parameters + /// Meaning + /// + /// + /// wParam + /// New bits per pixel + /// + /// + /// LOWORD(lParam) + /// New pixel width + /// + /// + /// HIWORD(lParam) + /// New pixel height + /// + /// + /// + /// To change the settings for more than one display at the same time, first call ChangeDisplaySettingsEx for each device + /// individually to update the registry without applying the changes. Then call ChangeDisplaySettingsEx once more, with a + /// NULL device, to apply the changes. For example, to change the settings for two displays, do the following: + /// + /// 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-changedisplaysettingsexa LONG ChangeDisplaySettingsExA( + // LPCSTR lpszDeviceName, DEVMODEA *lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "1448e04c-1452-4eab-bda4-4d249cb67a24")] + public static extern int ChangeDisplaySettingsEx([Optional] string lpszDeviceName, in DEVMODE lpDevMode, [Optional] HWND hwnd, [Optional] ChangeDisplaySettingsFlags dwflags, in VIDEOPARAMETERS lParam); /// /// The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method @@ -498,6 +1532,105 @@ namespace Vanara.PInvoke [PInvokeData("Winuser.h", MSDNShortId = "dd144871")] public static extern SafeHDC GetDC(HWND ptr); + /// + /// + /// The GetDCEx function retrieves a handle to a device context (DC) for the client area of a specified window or for the + /// entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque + /// data structure, whose values are used internally by GDI. + /// + /// + /// This function is an extension to the GetDC function, which gives an application more control over how and whether clipping occurs + /// in the client area. + /// + /// + /// + /// A handle to the window whose DC is to be retrieved. If this value is NULL, GetDCEx retrieves the DC for the entire screen. + /// + /// + /// A clipping region that may be combined with the visible region of the DC. If the value of flags is DCX_INTERSECTRGN or + /// DCX_EXCLUDERGN, then the operating system assumes ownership of the region and will automatically delete it when it is no longer + /// needed. In this case, the application should not use or delete the region after a successful call to GetDCEx. + /// + /// + /// Specifies how the DC is created. This parameter can be one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// DCX_WINDOW + /// Returns a DC that corresponds to the window rectangle rather than the client rectangle. + /// + /// + /// DCX_CACHE + /// Returns a DC from the cache, rather than the OWNDC or CLASSDC window. Essentially overrides CS_OWNDC and CS_CLASSDC. + /// + /// + /// DCX_PARENTCLIP + /// + /// Uses the visible region of the parent window. The parent's WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored. The origin is + /// set to the upper-left corner of the window identified by hWnd. + /// + /// + /// + /// DCX_CLIPSIBLINGS + /// Excludes the visible regions of all sibling windows above the window identified by hWnd. + /// + /// + /// DCX_CLIPCHILDREN + /// Excludes the visible regions of all child windows below the window identified by hWnd. + /// + /// + /// DCX_NORESETATTRS + /// This flag is ignored. + /// + /// + /// DCX_LOCKWINDOWUPDATE + /// + /// Allows drawing even if there is a LockWindowUpdate call in effect that would otherwise exclude this window. Used for drawing + /// during tracking. + /// + /// + /// + /// DCX_EXCLUDERGN + /// The clipping region identified by hrgnClip is excluded from the visible region of the returned DC. + /// + /// + /// DCX_INTERSECTRGN + /// The clipping region identified by hrgnClip is intersected with the visible region of the returned DC. + /// + /// + /// DCX_INTERSECTUPDATE + /// Reserved; do not use. + /// + /// + /// DCX_VALIDATE + /// Reserved; do not use. + /// + /// + /// + /// + /// If the function succeeds, the return value is the handle to the DC for the specified window. + /// + /// If the function fails, the return value is NULL. An invalid value for the hWnd parameter will cause the function to fail. + /// + /// + /// + /// + /// Unless the display DC belongs to a window class, the ReleaseDC function must be called to release the DC after painting. Also, + /// ReleaseDC must be called from the same thread that called GetDCEx. The number of DCs is limited only by available memory. + /// + /// + /// The function returns a handle to a DC that belongs to the window's class if CS_CLASSDC, CS_OWNDC or CS_PARENTDC was specified as + /// a style in the WNDCLASS structure when the class was registered. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getdcex HDC GetDCEx( HWND hWnd, HRGN hrgnClip, DWORD flags ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "590cf928-0ad6-43f8-97e9-1dafbcfa9f49")] + public static extern HDC GetDCEx(HWND hWnd, HRGN hrgnClip, DCX flags); + /// /// Retrieves the current color of the specified display element. Display elements are the parts of a window and the display that /// appear on the system display screen. @@ -529,6 +1662,97 @@ namespace Vanara.PInvoke [DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)] public static extern HBRUSH GetSysColorBrush(SystemColorIndex nIndex); + /// + /// The GetTabbedTextExtent function computes the width and height of a character string. If the string contains one or more + /// tab characters, the width of the string is based upon the specified tab stops. The GetTabbedTextExtent function uses the + /// currently selected font to compute the dimensions of the string. + /// + /// A handle to the device context. + /// A pointer to a character string. + /// + /// The length of the text string. For the ANSI function it is a BYTE count and for the Unicode function it is a WORD count. Note + /// that for the ANSI function, characters in SBCS code pages take one byte each, while most characters in DBCS code pages take two + /// bytes; for the Unicode function, most currently defined Unicode characters (those in the Basic Multilingual Plane (BMP)) are one + /// WORD while Unicode surrogates are two WORDs. + /// + /// The number of tab-stop positions in the array pointed to by the lpnTabStopPositions parameter. + /// + /// A pointer to an array containing the tab-stop positions, in device units. The tab stops must be sorted in increasing order; the + /// smallest x-value should be the first item in the array. + /// + /// + /// + /// If the function succeeds, the return value is the dimensions of the string in logical units. The height is in the high-order word + /// and the width is in the low-order word. + /// + /// + /// If the function fails, the return value is 0. GetTabbedTextExtent will fail if hDC is invalid and if nTabPositions is less + /// than 0. + /// + /// + /// + /// The current clipping region does not affect the width and height returned by the GetTabbedTextExtent function. + /// + /// Because some devices do not place characters in regular cell arrays (that is, they kern the characters), the sum of the extents + /// of the characters in a string may not be equal to the extent of the string. + /// + /// + /// If the nTabPositions parameter is zero and the lpnTabStopPositions parameter is NULL, tabs are expanded to eight times the + /// average character width. + /// + /// + /// If nTabPositions is 1, the tab stops are separated by the distance specified by the first value in the array to which + /// lpnTabStopPositions points. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettabbedtextextenta DWORD GetTabbedTextExtentA( HDC hdc, + // LPCSTR lpString, int chCount, int nTabPositions, const INT *lpnTabStopPositions ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "3444bb8d-4a30-47d4-b211-01f7cba39975")] + public static extern uint GetTabbedTextExtent(HDC hdc, string lpString, int chCount, int nTabPositions, [In] int[] lpnTabStopPositions); + + /// + /// The GetTabbedTextExtent function computes the width and height of a character string. If the string contains one or more + /// tab characters, the width of the string is based upon the specified tab stops. The GetTabbedTextExtent function uses the + /// currently selected font to compute the dimensions of the string. + /// + /// A handle to the device context. + /// A pointer to a character string. + /// + /// A pointer to an array containing the tab-stop positions, in device units. The tab stops must be sorted in increasing order; the + /// smallest x-value should be the first item in the array. + /// + /// + /// If the function succeeds, the return value is the dimensions of the string in logical units. + /// + /// If the function fails, the return value is Size.Empty. GetTabbedTextExtent will fail if hDC is invalid and if + /// nTabPositions is less than 0. + /// + /// + /// + /// The current clipping region does not affect the width and height returned by the GetTabbedTextExtent function. + /// + /// Because some devices do not place characters in regular cell arrays (that is, they kern the characters), the sum of the extents + /// of the characters in a string may not be equal to the extent of the string. + /// + /// + /// If the nTabPositions parameter is zero and the lpnTabStopPositions parameter is NULL, tabs are expanded to eight times the + /// average character width. + /// + /// + /// If nTabPositions is 1, the tab stops are separated by the distance specified by the first value in the array to which + /// lpnTabStopPositions points. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettabbedtextextenta DWORD GetTabbedTextExtentA( HDC hdc, + // LPCSTR lpString, int chCount, int nTabPositions, const INT *lpnTabStopPositions ); + [PInvokeData("winuser.h", MSDNShortId = "3444bb8d-4a30-47d4-b211-01f7cba39975")] + public static Size GetTabbedTextExtent(HDC hdc, string lpString, int[] lpnTabStopPositions) + { + var ret = GetTabbedTextExtent(hdc, lpString, lpString?.Length ?? 0, lpnTabStopPositions?.Length ?? 0, lpnTabStopPositions); + return new Size(Macros.LOWORD(ret), Macros.HIWORD(ret)); + } + /// /// Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra /// window memory. @@ -593,139 +1817,151 @@ namespace Vanara.PInvoke public static extern IntPtr GetWindowLongPtr(HWND hWnd, WindowLongFlags nIndex); /// - /// 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. + /// + /// [ LoadBitmap is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions. Instead, use LoadImage and DrawFrameControl.] + /// + /// The LoadBitmap function loads the specified bitmap resource from a module's executable file. /// - /// - /// 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. + /// A handle to the instance of the module whose executable file contains the bitmap to be loaded. + /// + /// A pointer to a null-terminated string that contains the name of the bitmap resource to be loaded. Alternatively, this parameter + /// can consist of the resource identifier in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can be + /// used to create this value. /// /// - /// 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. + /// If the function succeeds, the return value is the handle to the specified bitmap. + /// If the function fails, the return value is NULL. /// - [PInvokeData("WinUser.h", MSDNShortId = "")] - [DllImport(Lib.User32, ExactSpelling = true, SetLastError = true)] + /// + /// + /// If the bitmap pointed to by the lpBitmapName parameter does not exist or there is insufficient memory to load the bitmap, the + /// function fails. + /// + /// + /// LoadBitmap creates a compatible bitmap of the display, which cannot be selected to a printer. To load a bitmap that you + /// can select to a printer, call LoadImage and specify LR_CREATEDIBSECTION to create a DIB section. A DIB section can be selected to + /// any device. + /// + /// + /// An application can use the LoadBitmap function to access predefined bitmaps. To do so, the application must set the + /// hInstance parameter to NULL and the lpBitmapName parameter to one of the following values. + /// + /// + /// + /// Bitmap name + /// Bitmap name + /// + /// + /// OBM_BTNCORNERS + /// OBM_OLD_RESTORE + /// + /// + /// OBM_BTSIZE + /// OBM_OLD_RGARROW + /// + /// + /// OBM_CHECK + /// OBM_OLD_UPARROW + /// + /// + /// OBM_CHECKBOXES + /// OBM_OLD_ZOOM + /// + /// + /// OBM_CLOSE + /// OBM_REDUCE + /// + /// + /// OBM_COMBO + /// OBM_REDUCED + /// + /// + /// OBM_DNARROW + /// OBM_RESTORE + /// + /// + /// OBM_DNARROWD + /// OBM_RESTORED + /// + /// + /// OBM_DNARROWI + /// OBM_RGARROW + /// + /// + /// OBM_LFARROW + /// OBM_RGARROWD + /// + /// + /// OBM_LFARROWD + /// OBM_RGARROWI + /// + /// + /// OBM_LFARROWI + /// OBM_SIZE + /// + /// + /// OBM_MNARROW + /// OBM_UPARROW + /// + /// + /// OBM_OLD_CLOSE + /// OBM_UPARROWD + /// + /// + /// OBM_OLD_DNARROW + /// OBM_UPARROWI + /// + /// + /// OBM_OLD_LFARROW + /// OBM_ZOOM + /// + /// + /// OBM_OLD_REDUCE + /// OBM_ZOOMD + /// + /// + /// Bitmap names that begin with OBM_OLD represent bitmaps used by 16-bit versions of Windows earlier than 3.0. + /// + /// For an application to use any of the OBM_ constants, the constant OEMRESOURCE must be defined before the Windows.h header file is included. + /// + /// The application must call the DeleteObject function to delete each bitmap handle returned by the LoadBitmap function. + /// Examples + /// For an example, see Example of Menu-Item Bitmaps in Using Menus. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-loadbitmapa HBITMAP LoadBitmapA( HINSTANCE hInstance, + // LPCSTR lpBitmapName ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "5eed5f78-deaf-4b23-986e-4802dc05936c")] + public static extern SafeHBITMAP LoadBitmap(HINSTANCE hInstance, [In] SafeResourceId lpBitmapName); + + /// + /// The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the + /// ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs. + /// + /// A handle to the window whose DC is to be released. + /// A handle to the DC to be released. + /// + /// The return value indicates whether the DC was released. If the DC was released, the return value is 1. + /// If the DC was not released, the return value is zero. + /// + /// + /// + /// The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC + /// function that retrieves a common DC. + /// + /// + /// An application cannot use the ReleaseDC function to release a DC that was created by calling the CreateDC function; + /// instead, it must use the DeleteDC function. ReleaseDC must be called from the same thread that called GetDC. + /// + /// Examples + /// For an example, see Scaling an Image. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-releasedc int ReleaseDC( HWND hWnd, HDC hDC ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "c4f48f1e-4a37-4330-908e-2ac5c65e1a1d")] [return: MarshalAs(UnmanagedType.Bool)] - [System.Security.SecurityCritical] - public static extern bool InvalidateRect(HWND hWnd, [In, Optional] PRECT rect, [MarshalAs(UnmanagedType.Bool)] bool bErase); - - /// - /// 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); + public static extern bool ReleaseDC(HWND hWnd, HDC hDC); /// /// @@ -848,6 +2084,76 @@ namespace Vanara.PInvoke return ret.ToInt32(); } + /// + /// The TabbedTextOut function writes a character string at a specified location, expanding tabs to the values specified in an + /// array of tab-stop positions. Text is written in the currently selected font, background color, and text color. + /// + /// A handle to the device context. + /// The x-coordinate of the starting point of the string, in logical units. + /// The y-coordinate of the starting point of the string, in logical units. + /// + /// A pointer to the character string to draw. The string does not need to be zero-terminated, since nCount specifies the length of + /// the string. + /// + /// The length of the string pointed to by lpString. + /// The number of values in the array of tab-stop positions. + /// + /// A pointer to an array containing the tab-stop positions, in logical units. The tab stops must be sorted in increasing order; the + /// smallest x-value should be the first item in the array. + /// + /// The x-coordinate of the starting position from which tabs are expanded, in logical units. + /// + /// + /// If the function succeeds, the return value is the dimensions, in logical units, of the string. The height is in the high-order + /// word and the width is in the low-order word. + /// + /// If the function fails, the return value is zero. + /// + /// + /// + /// If the nTabPositions parameter is zero and the lpnTabStopPositions parameter is NULL, tabs are expanded to eight times the + /// average character width. + /// + /// + /// If nTabPositions is 1, the tab stops are separated by the distance specified by the first value in the lpnTabStopPositions array. + /// + /// + /// If the lpnTabStopPositions array contains more than one value, a tab stop is set for each value in the array, up to the number + /// specified by nTabPositions. + /// + /// + /// The nTabOrigin parameter allows an application to call the TabbedTextOut function several times for a single line. If the + /// application calls TabbedTextOut more than once with the nTabOrigin set to the same value each time, the function expands + /// all tabs relative to the position specified by nTabOrigin. + /// + /// + /// By default, the current position is not used or updated by the TabbedTextOut function. If an application needs to update + /// the current position when it calls TabbedTextOut, the application can call the SetTextAlign function with the wFlags + /// parameter set to TA_UPDATECP. When this flag is set, the system ignores the X and Y parameters on subsequent calls to the + /// TabbedTextOut function, using the current position instead. + /// + /// Note For Windows Vista and later, TabbedTextOut ignores text alignment when it draws text. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-tabbedtextouta LONG TabbedTextOutA( HDC hdc, int x, int y, + // LPCSTR lpString, int chCount, int nTabPositions, const INT *lpnTabStopPositions, int nTabOrigin ); + [DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("winuser.h", MSDNShortId = "1cb78a75-752d-4e06-afdf-cd797f209114")] + public static extern int TabbedTextOut(HDC hdc, int x, int y, string lpString, int chCount, [Optional] int nTabPositions, [In, Optional] int[] lpnTabStopPositions, int nTabOrigin); + + /// + /// The WindowFromDC function returns a handle to the window associated with the specified display device context (DC). Output + /// functions that use the specified device context draw into this window. + /// + /// Handle to the device context from which a handle to the associated window is to be retrieved. + /// + /// The return value is a handle to the window associated with the specified DC. If no window is associated with the specified DC, + /// the return value is NULL. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-windowfromdc HWND WindowFromDC( HDC hDC ); + [DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("winuser.h", MSDNShortId = "57ecec82-03be-4d1a-84cf-6b64131af19d")] + public static extern HWND WindowFromDC(HDC hDC); + private static SafeCoTaskMemHandle GetPtr(in T val) => SafeCoTaskMemHandle.CreateFromStructure(val); ///