From f1a3b2de88114c4941f79e775dc52855a2e66b70 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sun, 15 Jan 2023 15:43:16 -0700 Subject: [PATCH] Updated DWMWINDOWATTRIBUTE with new Win11 values --- PInvoke/DwmApi/DwmApi.cs | 143 +++++++++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 52 deletions(-) diff --git a/PInvoke/DwmApi/DwmApi.cs b/PInvoke/DwmApi/DwmApi.cs index 3f8b09737..f9254480a 100644 --- a/PInvoke/DwmApi/DwmApi.cs +++ b/PInvoke/DwmApi/DwmApi.cs @@ -205,18 +205,42 @@ public enum DWMTRANSITION_OWNEDWINDOW_TARGET DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0, } - /// Flags used by the DwmSetWindowAttribute function to specify the rounded corner preference for a window. - [PInvokeData("dwmapi.h")] + /// Flags for specifying the system-drawn backdrop material of a window, including behind the non-client area. + // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type + // typedef enum DWM_SYSTEMBACKDROP_TYPE { DWMSBT_AUTO, DWMSBT_NONE, DWMSBT_MAINWINDOW, DWMSBT_TRANSIENTWINDOW, DWMSBT_TABBEDWINDOW } ; + [PInvokeData("dwmapi.h", MSDNShortId = "NE:dwmapi.DWM_SYSTEMBACKDROP_TYPE")] + public enum DWM_SYSTEMBACKDROP_TYPE + { + /// + /// The default. Let the Desktop Window Manager (DWM) automatically decide the system-drawn backdrop material for this window. + /// + DWMSBT_AUTO, + + /// Don't draw any system backdrop. + DWMSBT_NONE, + + /// Draw the backdrop material effect corresponding to a long-lived window. + DWMSBT_MAINWINDOW, + + /// Draw the backdrop material effect corresponding to a transient window. + DWMSBT_TRANSIENTWINDOW, + + /// Draw the backdrop material effect corresponding to a window with a tabbed title bar. + DWMSBT_TABBEDWINDOW, + } + + /// Flags used by the DwmSetWindowAttribute function to specify the rounded corner preference for a window. + [PInvokeData("dwmapi.h")] public enum DWM_WINDOW_CORNER_PREFERENCE { - /// Let the system decide when to round window corners. - DWMWCP_DEFAULT = 0, - /// Never round window corners. - DWMWCP_DONOTROUND = 1, - /// Round the corners, if appropriate. - DWMWCP_ROUND = 2, - /// Round the corners if appropriate, with a small radius. - DWMWCP_ROUNDSMALL = 3 + /// Let the system decide when to round window corners. + DWMWCP_DEFAULT = 0, + /// Never round window corners. + DWMWCP_DONOTROUND = 1, + /// Round the corners, if appropriate. + DWMWCP_ROUND = 2, + /// Round the corners if appropriate, with a small radius. + DWMWCP_ROUNDSMALL = 3 } /// @@ -363,61 +387,76 @@ public enum DWMWINDOWATTRIBUTE /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_FREEZE_REPRESENTATION, - /// - /// Use with DwmSetWindowAttribute. Enables a non-UWP window to use host backdrop brushes. If this flag is set, then a Win32 app + + /// + /// Use with DwmSetWindowAttribute. Enables a non-UWP window to use host backdrop brushes. If this flag is set, then a Win32 app /// that calls Windows::UI::Composition APIs can build transparency effects using the host backdrop brush /// (see Compositor.CreateHostBackdropBrush). The pvAttribute parameter points to a value of type BOOL. TRUE to enable host /// backdrop brushes for the window, or FALSE to disable it. - ///Windows 10 and earlier: This value is not supported. - /// + ///This value is supported starting with Windows 11 Build 22000. + /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] - DWMWA_USE_HOSTBACKDROPBRUSH, - /// - /// Use with DwmSetWindowAttribute. Allows the window frame for this window to be drawn in dark mode colors when the dark mode + DWMWA_USE_HOSTBACKDROPBRUSH, + + /// + /// Use with DwmSetWindowAttribute. Allows the window frame for this window to be drawn in dark mode colors when the dark mode /// system setting is enabled. For compatibility reasons, all windows default to light mode regardless of the system setting. /// The pvAttribute parameter points to a value of type BOOL. TRUE to honor dark mode for the window, FALSE to always /// use light mode. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(bool), CorrespondingAction.Set)] - DWMWA_USE_IMMERSIVE_DARK_MODE = 20, - /// - /// Use with DwmSetWindowAttribute. Specifies the rounded corner preference for a window. The pvAttribute parameter points + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(bool), CorrespondingAction.Set)] + DWMWA_USE_IMMERSIVE_DARK_MODE = 20, + + /// + /// Use with DwmSetWindowAttribute. Specifies the rounded corner preference for a window. The pvAttribute parameter points /// to a value of type DWM_WINDOW_CORNER_PREFERENCE. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(DWM_WINDOW_CORNER_PREFERENCE), CorrespondingAction.Set)] - DWMWA_WINDOW_CORNER_PREFERENCE = 33, - /// - /// Use with DwmSetWindowAttribute. Specifies the color of the window border. The pvAttribute parameter points to a value + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(DWM_WINDOW_CORNER_PREFERENCE), CorrespondingAction.Set)] + DWMWA_WINDOW_CORNER_PREFERENCE = 33, + + /// + /// Use with DwmSetWindowAttribute. Specifies the color of the window border. The pvAttribute parameter points to a value /// of type COLORREF. The app is responsible for changing the border color according to state changes, such as a change /// in window activation. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] - DWMWA_BORDER_COLOR, - /// - /// Use with DwmSetWindowAttribute. Specifies the color of the caption. The pvAttribute parameter points to a value + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] + DWMWA_BORDER_COLOR, + + /// + /// Use with DwmSetWindowAttribute. Specifies the color of the caption. The pvAttribute parameter points to a value /// of type COLORREF. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] - DWMWA_CAPTION_COLOR, - /// - /// Use with DwmSetWindowAttribute. Specifies the color of the caption text. The pvAttribute parameter points to a value + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] + DWMWA_CAPTION_COLOR, + + /// + /// Use with DwmSetWindowAttribute. Specifies the color of the caption text. The pvAttribute parameter points to a value /// of type COLORREF. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] - DWMWA_TEXT_COLOR, - /// - /// Use with DwmGetWindowAttribute. Retrieves the width of the outer border that the DWM would draw around this window. + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(COLORREF), CorrespondingAction.Set)] + DWMWA_TEXT_COLOR, + + /// + /// Use with DwmGetWindowAttribute. Retrieves the width of the outer border that the DWM would draw around this window. /// The value can vary depending on the DPI of the window. The pvAttribute parameter points to a value of type UINT. - /// Windows 10 and earlier: This value is not supported. - /// - [CorrespondingType(typeof(uint), CorrespondingAction.Set)] - DWMWA_VISIBLE_FRAME_BORDER_THICKNESS - } + /// This value is supported starting with Windows 11 Build 22000. + /// + [CorrespondingType(typeof(uint), CorrespondingAction.Get)] + DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, + + /// + /// Use with DwmGetWindowAttribute or DwmSetWindowAttribute. Retrieves or specifies the system-drawn backdrop material of a + /// window, including behind the non-client area. The pvAttribute parameter points to a value of type DWM_SYSTEMBACKDROP_TYPE. + /// This value is supported starting with Windows 11 Build 22621. + /// + [CorrespondingType(typeof(DWM_SYSTEMBACKDROP_TYPE), CorrespondingAction.GetSet)] + DWMWA_SYSTEMBACKDROP_TYPE, + } /// Identifies the gesture type specified in DwmRenderGesture. [PInvokeData("dwmapi.h")]