namespace Vanara.PInvoke; /// Encapsulates classes exposed by DWNAPI.DLL public static partial class DwmApi { /// Use this constant to reset any window part colors to the system default behavior public const uint DWMWA_COLOR_DEFAULT = 0xFFFFFFFF; /// Use this constant to specify that a window part should not be rendered public const uint DWMWA_COLOR_NONE = 0xFFFFFFFE; /// Flags used by the DWM_BLURBEHIND structure to indicate which of its members contain valid information. [Flags] [PInvokeData("dwmapi.h")] public enum DWM_BLURBEHIND_Mask { /// A value for the fEnable member has been specified. DWM_BB_ENABLE = 0X00000001, /// A value for the hRgnBlur member has been specified. DWM_BB_BLURREGION = 0X00000002, /// A value for the fTransitionOnMaximized member has been specified. DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004 } /// Flags used by the DwmSetWindowAttribute function to specify the cloaking reason [Flags] [PInvokeData("dwmapi.h")] public enum DWM_CLOAKED { /// The window was cloaked by its owner application. DWM_CLOAKED_APP = 0x0000001, /// The window was cloaked by the Shell. DWM_CLOAKED_SHELL = 0x0000002, /// The cloak value was inherited from its owner window. DWM_CLOAKED_INHERITED = 0x0000004, } /// The display options for the live preview. [Flags] [PInvokeData("dwmapi.h")] public enum DWM_SETICONICPREVIEW_Flags { /// No frame is displayed around the provided thumbnail. DWM_SIT_NONE = 0x00000000, /// Displays a frame around the provided bitmap. DWM_SIT_DISPLAYFRAME = 0x00000001, } /// Visualizations that DWM should show for a contact. [Flags] [PInvokeData("dwmapi.h")] public enum DWM_SHOWCONTACT : uint { /// No visual feedback should be shown in reponse to the contact. DWMSC_NONE = 0x00000000, /// Show the "contact down" animation, such as would be used in a button press. DWMSC_DOWN = 0x00000001, /// Show the "contact up" animation, such as would be used in a button release. DWMSC_UP = 0x00000002, /// Show the "contact drag" animation when the UI element that was selected by the touch or pen is dragged. DWMSC_DRAG = 0x00000004, /// Show a visual while the contact is held down, such as holding down a button. DWMSC_HOLD = 0x00000008, /// Show the pen barrel visual when the pen barrel button is pressed. DWMSC_PENBARREL = 0x00000010, /// Show any of the animations if called for. DWMSC_ALL = 0xFFFFFFFF } /// /// Returned by DwmGetUnmetTabRequirements to indicate the requirements needed for a window to put tabs in the application title bar. /// // https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/ne-dwmapi-dwm_tab_window_requirements typedef enum // DWM_TAB_WINDOW_REQUIREMENTS { DWMTWR_NONE, DWMTWR_IMPLEMENTED_BY_SYSTEM, DWMTWR_WINDOW_RELATIONSHIP, DWMTWR_WINDOW_STYLES, // DWMTWR_WINDOW_REGION, DWMTWR_WINDOW_DWM_ATTRIBUTES, DWMTWR_WINDOW_MARGINS, DWMTWR_TABBING_ENABLED, DWMTWR_USER_POLICY, // DWMTWR_GROUP_POLICY, DWMTWR_APP_COMPAT } ; [PInvokeData("dwmapi.h", MSDNShortId = "8366ABE4-263D-448D-9FC9-3F4DAF9B700D")] [Flags] public enum DWM_TAB_WINDOW_REQUIREMENTS { /// The window meets all requirements requested. DWMTWR_NONE = 0x0000, /// /// In some configurations, the admin/user setting or mode of the system means that windows won't be tabbed. This requirement /// indicates that the system mode must implement tabbing. If the system does not implement tabbing, nothing can be done to /// change this. /// DWMTWR_IMPLEMENTED_BY_SYSTEM = 0x0001, /// The window has an owner or parent, and is therefore ineligible for tabbing. DWMTWR_WINDOW_RELATIONSHIP = 0x0002, /// /// The window has one or more styles that make it ineligible for tabbing. To be eligible for tabbing, a window must: /// DWMTWR_WINDOW_STYLES = 0x0004, /// The window has a region (set using SetWindowRgn) making it ineligible. DWMTWR_WINDOW_REGION = 0x0008, /// /// The window is ineligible due to its Dwm configuration. To resolve this issue, the window must not extended its client area /// into the title bar using DwmExtendFrameIntoClientArea. In addition, the window must not have DWMWA_NCRENDERING_POLICY set to DWMNCRP_ENABLED. /// DWMTWR_WINDOW_DWM_ATTRIBUTES = 0x0010, /// /// The window is ineligible due to its margins, most likely due to custom handling in WM_NCCALCSIZE. To resolve this issue, the /// window must use the default window margins for the non-client area. /// DWMTWR_WINDOW_MARGINS = 0x0020, /// The window has been explicitly opted out by setting DWMWA_TABBING_ENABLED to false. DWMTWR_TABBING_ENABLED = 0x0040, /// The user has configured this application to not participate in tabbing. DWMTWR_USER_POLICY = 0x0080, /// The group policy has configured this application to not participate in tabbing. DWMTWR_GROUP_POLICY = 0x0100, /// /// This is set if app compat has blocked tabs for this window. Can be overridden per window by setting DWMWA_TABBING_ENABLED to /// TRUE. That does not override any other tabbing requirements. /// DWMTWR_APP_COMPAT = 0x0200, } /// Flags used by the DWM_THUMBNAIL_PROPERTIES structure to indicate which of its members contain valid information. [Flags] [PInvokeData("dwmapi.h")] public enum DWM_TNP : uint { /// A value for the rcDestination member has been specified. DWM_TNP_RECTDESTINATION = 0x00000001, /// A value for the rcSource member has been specified. DWM_TNP_RECTSOURCE = 0x00000002, /// A value for the opacity member has been specified. DWM_TNP_OPACITY = 0x00000004, /// A value for the fVisible member has been specified. DWM_TNP_VISIBLE = 0x00000008, /// A value for the fSourceClientAreaOnly member has been specified. DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010, } /// Flags used by the DwmSetWindowAttribute function to specify the Flip3D window policy. [PInvokeData("dwmapi.h")] public enum DWMFLIP3DWINDOWPOLICY { /// /// Use the window's style and visibility settings to determine whether to hide or include the window in Flip3D rendering. /// DWMFLIP3D_DEFAULT, /// Exclude the window from Flip3D and display it below the Flip3D rendering. DWMFLIP3D_EXCLUDEBELOW, /// Exclude the window from Flip3D and display it above the Flip3D rendering. DWMFLIP3D_EXCLUDEABOVE, /// The maximum recognized DWMFLIP3DWINDOWPOLICY value, used for validation purposes. DWMFLIP3D_LAST } /// Flags used by the DwmSetWindowAttribute function to specify the non-client area rendering policy. [PInvokeData("dwmapi.h")] public enum DWMNCRENDERINGPOLICY { /// The non-client rendering area is rendered based on the window style. DWMNCRP_USEWINDOWSTYLE, /// The non-client area rendering is disabled; the window style is ignored. DWMNCRP_DISABLED, /// The non-client area rendering is enabled; the window style is ignored. DWMNCRP_ENABLED, /// The maximum recognized DWMNCRENDERINGPOLICY value, used for validation purposes. DWMNCRP_LAST } /// Identifies the target. [PInvokeData("dwmapi.h")] public enum DWMTRANSITION_OWNEDWINDOW_TARGET { /// Indicates no animation. DWMTRANSITION_OWNEDWINDOW_NULL = -1, /// Indicates that the window is repositioned. DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0, } /// 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 } /// /// Flags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions to specify window attributes for non-client rendering. /// [PInvokeData("dwmapi.h")] public enum DWMWINDOWATTRIBUTE { /// /// Use with DwmGetWindowAttribute. Discovers whether non-client rendering is enabled. The retrieved value is of type BOOL. TRUE /// if non-client rendering is enabled; otherwise, FALSE. /// [CorrespondingType(typeof(bool), CorrespondingAction.Get)] DWMWA_NCRENDERING_ENABLED = 1, /// /// Use with DwmSetWindowAttribute. Sets the non-client rendering policy. The pvAttribute parameter points to a value from the /// DWMNCRENDERINGPOLICY enumeration. /// [CorrespondingType(typeof(DWMNCRENDERINGPOLICY), CorrespondingAction.Set)] DWMWA_NCRENDERING_POLICY, /// /// Use with DwmSetWindowAttribute. Enables or forcibly disables DWM transitions. The pvAttribute parameter points to a value of /// TRUE to disable transitions or FALSE to enable transitions. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_TRANSITIONS_FORCEDISABLED, /// /// Use with DwmSetWindowAttribute. Enables content rendered in the non-client area to be visible on the frame drawn by DWM. The /// pvAttribute parameter points to a value of TRUE to enable content rendered in the non-client area to be visible on the frame; /// otherwise, it points to FALSE. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_ALLOW_NCPAINT, /// /// Use with DwmGetWindowAttribute. Retrieves the bounds of the caption button area in the window-relative space. The retrieved /// value is of type RECT. /// [CorrespondingType(typeof(RECT), CorrespondingAction.Get)] DWMWA_CAPTION_BUTTON_BOUNDS, /// /// Use with DwmSetWindowAttribute. Specifies whether non-client content is right-to-left (RTL) mirrored. The pvAttribute /// parameter points to a value of TRUE if the non-client content is right-to-left (RTL) mirrored; otherwise, it points to FALSE. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_NONCLIENT_RTL_LAYOUT, /// /// Use with DwmSetWindowAttribute. Forces the window to display an iconic thumbnail or peek representation (a static bitmap), /// even if a live or snapshot representation of the window is available. This value normally is set during a window's creation /// and not changed throughout the window's lifetime. Some scenarios, however, might require the value to change over time. The /// pvAttribute parameter points to a value of TRUE to require a iconic thumbnail or peek representation; otherwise, it points to FALSE. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_FORCE_ICONIC_REPRESENTATION, /// /// Use with DwmSetWindowAttribute. Sets how Flip3D treats the window. The pvAttribute parameter points to a value from the /// DWMFLIP3DWINDOWPOLICY enumeration. /// [CorrespondingType(typeof(DWMFLIP3DWINDOWPOLICY), CorrespondingAction.Set)] DWMWA_FLIP3D_POLICY, /// /// Use with DwmGetWindowAttribute. Retrieves the extended frame bounds rectangle in screen space. The retrieved value is of type RECT. /// [CorrespondingType(typeof(RECT), CorrespondingAction.Get)] DWMWA_EXTENDED_FRAME_BOUNDS, /// /// Use with DwmSetWindowAttribute. The window will provide a bitmap for use by DWM as an iconic thumbnail or peek representation /// (a static bitmap) for the window. DWMWA_HAS_ICONIC_BITMAP can be specified with DWMWA_FORCE_ICONIC_REPRESENTATION. /// DWMWA_HAS_ICONIC_BITMAP normally is set during a window's creation and not changed throughout the window's lifetime. Some /// scenarios, however, might require the value to change over time. The pvAttribute parameter points to a value of TRUE to /// inform DWM that the window will provide an iconic thumbnail or peek representation; otherwise, it points to FALSE. /// Windows Vista and earlier: This value is not supported. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_HAS_ICONIC_BITMAP, /// /// Use with DwmSetWindowAttribute. Do not show peek preview for the window. The peek view shows a full-sized preview of the /// window when the mouse hovers over the window's thumbnail in the taskbar. If this attribute is set, hovering the mouse pointer /// over the window's thumbnail dismisses peek (in case another window in the group has a peek preview showing). The pvAttribute /// parameter points to a value of TRUE to prevent peek functionality or FALSE to allow it. /// Windows Vista and earlier: This value is not supported. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_DISALLOW_PEEK, /// /// Use with DwmSetWindowAttribute. Prevents a window from fading to a glass sheet when peek is invoked. The pvAttribute /// parameter points to a value of TRUE to prevent the window from fading during another window's peek or FALSE for normal behavior. /// Windows Vista and earlier: This value is not supported. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_EXCLUDED_FROM_PEEK, /// /// Use with DwmSetWindowAttribute. Cloaks the window such that it is not visible to the user. The window is still composed by DWM. /// /// Using with DirectComposition: Use the DWMWA_CLOAK flag to cloak the layered child window when animating a /// representation of the window's content via a DirectComposition visual which has been associated with the layered child /// window. For more details on this usage case, see How to How to animate the bitmap of a layered child window. /// /// Windows 7 and earlier: This value is not supported. /// [CorrespondingType(typeof(bool), CorrespondingAction.Set)] DWMWA_CLOAK, /// /// Use with DwmGetWindowAttribute. If the window is cloaked, provides one of the following values explaining why: /// /// /// Name (Value) /// Meaning /// /// /// DWM_CLOAKED_APP 0x0000001 /// The window was cloaked by its owner application. /// /// /// DWM_CLOAKED_SHELL 0x0000002 /// The window was cloaked by the Shell. /// /// /// DWM_CLOAKED_INHERITED 0x0000004 /// The cloak value was inherited from its owner window. /// /// /// Windows 7 and earlier: This value is not supported. /// [CorrespondingType(typeof(DWM_CLOAKED), CorrespondingAction.Get)] DWMWA_CLOAKED, /// /// Use with DwmSetWindowAttribute. Freeze the window's thumbnail image with its current visuals. Do no further live updates on /// the thumbnail image to match the window's contents. /// Windows 7 and earlier: This value is not supported. /// [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 /// 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. ///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 /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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")] public enum GESTURE_TYPE { /// A pen tap. GT_PEN_TAP = 0, /// A pen double tap. GT_PEN_DOUBLETAP = 1, /// A pen right tap. GT_PEN_RIGHTTAP = 2, /// A pen press and hold. GT_PEN_PRESSANDHOLD = 3, /// An abort of the pen press and hold. GT_PEN_PRESSANDHOLDABORT = 4, /// A touch tap. GT_TOUCH_TAP = 5, /// A touch double tap. GT_TOUCH_DOUBLETAP = 6, /// A touch right tap. GT_TOUCH_RIGHTTAP = 7, /// A touch press and hold. GT_TOUCH_PRESSANDHOLD = 8, /// An abort of the touch press and hold. GT_TOUCH_PRESSANDHOLDABORT = 9, /// A touch press and tap. GT_TOUCH_PRESSANDTAP = 10 } /// Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area. /// A handle to the window procedure that received the message. /// The message. /// /// Specifies additional message information. The content of this parameter depends on the value of the msg parameter. /// /// /// Specifies additional message information. The content of this parameter depends on the value of the msg parameter. /// /// /// A pointer to an LRESULT value that, when this method returns successfully,receives the result of the hit test. /// /// TRUE if DwmDefWindowProc handled the message; otherwise, FALSE. [DllImport(Lib.DwmApi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("dwmapi.h")] public static extern bool DwmDefWindowProc(HWND hwnd, uint msg, IntPtr wParam, IntPtr lParam, out IntPtr plResult); /// Enables the blur effect on a specified window. /// The handle to the window on which the blur behind data is applied. /// A pointer to a DWM_BLURBEHIND structure that provides blur behind data. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmEnableBlurBehindWindow(HWND hWnd, in DWM_BLURBEHIND pDwmBlurbehind); /// /// Enables or disables Desktop Window Manager (DWM) composition. This function is deprecated as of Windows 8. DWM can no /// longer be programmatically disabled. /// /// /// DWM_EC_ENABLECOMPOSITION to enable DWM composition; DWM_EC_DISABLECOMPOSITION to disable composition. As of Windows 8, /// calling this function with DWM_EC_DISABLECOMPOSITION has no effect. However, the function will still return a success code. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmEnableComposition([MarshalAs(UnmanagedType.Bool)] bool uCompositionAction); /// /// Notifies the Desktop Window Manager (DWM) to opt in to or out of Multimedia Class Schedule Service (MMCSS) scheduling while the /// calling process is alive. /// /// /// TRUE to instruct DWM to participate in MMCSS scheduling; FALSE to opt out or end participation in MMCSS scheduling. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmEnableMMCSS([MarshalAs(UnmanagedType.Bool)] bool fEnableMMCSS); /// Extends the window frame into the client area. /// The handle to the window in which the frame will be extended into the client area. /// /// A pointer to a MARGINS structure that describes the margins to use when extending the frame into the client area. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmExtendFrameIntoClientArea(HWND hWnd, in MARGINS pMarInset); /// /// Issues a flush call that blocks the caller until the next present, when all of the Microsoft DirectX surface updates that are /// currently outstanding have been made. This compensates for very complex scenes or calling processes with very low priority. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmFlush(); /// /// Retrieves the current color used for Desktop Window Manager (DWM) glass composition. This value is based on the current color /// scheme and can be modified by the user. Applications can listen for color changes by handling the WM_DWMCOLORIZATIONCOLORCHANGED notification. /// /// /// A pointer to a value that, when this function returns successfully, receives the current color used for glass composition. The /// color format of the value is 0xAARRGGBB. /// /// /// A pointer to a value that, when this function returns successfully, indicates whether the color is an opaque blend. TRUE if the /// color is an opaque blend; otherwise, FALSE. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmGetColorizationColor(out uint pcrColorization, [MarshalAs(UnmanagedType.Bool)] out bool pfOpaqueBlend); /// Retrieves the current composition timing information for a specified window. /// /// The handle to the window for which the composition timing information should be retrieved. Starting with Windows 8.1, this /// parameter must be set to NULL. If this parameter is not set to NULL, DwmGetCompositionTimingInfo returns E_INVALIDARG. /// /// /// A pointer to a DWM_TIMING_INFO structure that, when this function returns successfully, receives the current composition timing /// information for the window. The cbSize member of this structure must be set before this function is called. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmGetCompositionTimingInfo([Optional] HWND hwnd, ref DWM_TIMING_INFO dwAttribute); /// Retrieves transport attributes. /// /// A pointer to a BOOL value that indicates whether the transport supports remoting. TRUE if the transport supports remoting; /// otherwise, FALSE. /// /// /// A pointer to a BOOL value that indicates whether the transport is connected. TRUE if the transport is connected; otherwise, FALSE. /// /// A pointer to a DWORD that receives a generation value for the transport. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmGetTransportAttributes([MarshalAs(UnmanagedType.Bool)] out bool pfIsRemoting, [MarshalAs(UnmanagedType.Bool)] out bool pfIsConnected, out uint pDwGeneration); /// /// Note This function is publicly available, but nonfunctional, for Windows 10, version 1803. /// Checks the requirements needed to get tabs in the application title bar for the specified window. /// /// The handle of the window to check. /// The value. /// None // https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmgetunmettabrequirements // DWMAPI DwmGetUnmetTabRequirements( HWND appWindow, DWM_TAB_WINDOW_REQUIREMENTS *value ); [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h", MSDNShortId = "8E67E1BE-D6FC-4A8A-8E71-45B6F337E3BD")] public static extern HRESULT DwmGetUnmetTabRequirements(HWND appWindow, out DWM_TAB_WINDOW_REQUIREMENTS value); /// Retrieves the current value of a specified attribute applied to a window. /// The handle to the window from which the attribute data is retrieved. /// The attribute to retrieve, specified as a DWMWINDOWATTRIBUTE value. /// /// A pointer to a value that, when this function returns successfully, receives the current value of the attribute. The type of the /// retrieved value depends on the value of the dwAttribute parameter. /// /// /// The size of the DWMWINDOWATTRIBUTE value being retrieved. The size is dependent on the type of the pvAttribute parameter. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmGetWindowAttribute(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, IntPtr pvAttribute, int cbAttribute); /// Retrieves the current value of a specified attribute applied to a window. /// The handle to the window from which the attribute data is retrieved. /// The attribute to retrieve, specified as a DWMWINDOWATTRIBUTE value. /// /// A value that, when this function returns successfully, receives the current value of the attribute. The type of the retrieved /// value depends on the value of the dwAttribute parameter. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [PInvokeData("dwmapi.h")] public static HRESULT DwmGetWindowAttribute(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, out T? pvAttribute) { if (!CorrespondingTypeAttribute.CanGet(dwAttribute, typeof(T))) throw new ArgumentException(); var m = SafeCoTaskMemHandle.CreateFromStructure(); var hr = DwmGetWindowAttribute(hwnd, dwAttribute, m, m.Size); pvAttribute = m.ToType(); return hr; } /// /// Called by an application to indicate that all previously provided iconic bitmaps from a window, both thumbnails and peek /// representations, should be refreshed. /// /// /// A handle to the window or tab whose bitmaps are being invalidated through this call. This window must belong to the calling process. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// Calling this function causes the Desktop Window Manager (DWM) to invalidate its current bitmaps for the window and request new /// bitmaps from the window when they are next needed. DwmInvalidateIconicBitmaps should not be called frequently. Doing so can lead /// to poor performance as new bitmaps are created and retrieved. /// [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmInvalidateIconicBitmaps(HWND hwnd); /// /// Obtains a value that indicates whether Desktop Window Manager (DWM) composition is enabled. Applications on machines running /// Windows 7 or earlier can listen for composition state changes by handling the WM_DWMCOMPOSITIONCHANGED notification. /// /// /// A pointer to a value that, when this function returns successfully, receives TRUE if DWM composition is enabled; otherwise, /// FALSE. As of Windows 8, DWM composition is always enabled. If an app declares Windows 8 compatibility in their manifest, /// this function will receive a value of TRUE through pfEnabled. If no such manifest entry is found, Windows 8 compatibility is not /// assumed and this function receives a value of FALSE through pfEnabled. This is done so that older programs that interpret a value /// of TRUE to imply that high contrast mode is off can continue to make the correct decisions about rendering their images. (Note /// that this is a bad practice—you should use the SystemParametersInfo function with the SPI_GETHIGHCONTRAST flag to determine the /// state of high contrast mode.) /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmIsCompositionEnabled([MarshalAs(UnmanagedType.Bool)] out bool pfEnabled); /// Gets the colorization parameters. /// The parameters. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmpGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters); /// Sets the colorization parameters. /// The parameters. /// Always set to 1. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmpSetColorizationParameters(in DWM_COLORIZATION_PARAMS parameters, uint unk = 1); /// Retrieves the source size of the Desktop Window Manager (DWM) thumbnail. /// A handle to the thumbnail to retrieve the source window size from. /// /// A pointer to a SIZE structure that, when this function returns successfully, receives the size of the source thumbnail. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmQueryThumbnailSourceSize(HTHUMBNAIL hThumbnail, out SIZE pSize); /// Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows. /// /// The handle to the window that will use the DWM thumbnail. Setting the destination window handle to anything other than a /// top-level window type will result in a return value of E_INVALIDARG. /// /// /// The handle to the window to use as the thumbnail source. Setting the source window handle to anything other than a top-level /// window type will result in a return value of E_INVALIDARG. /// /// /// A pointer to a handle that, when this function returns successfully, represents the registration of the DWM thumbnail. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmRegisterThumbnail(HWND hwndDestination, HWND hwndSource, out HTHUMBNAIL phThumbnailId); /// /// Notifies Desktop Window Manager (DWM) that a touch contact has been recognized as a gesture, and that DWM should draw feedback /// for that gesture. /// /// The type of gesture, specified as one of the GESTURE_TYPE values. /// The number of contact points. /// The pointer ID. /// The points. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmRenderGesture(GESTURE_TYPE gt, uint cContacts, ref uint pdwPointerID, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINT[] pPoints); /// /// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use /// this bitmap to show a full-sized preview of a window or tab. /// /// A handle to the window. This window must belong to the calling process. /// A handle to the bitmap to represent the window that hwnd specifies. /// /// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This /// offset enables the tab window's contents to be drawn correctly in a live preview when it is drawn without its frame. /// /// The display options for the live preview. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, HBITMAP hbmp, in POINT pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags); /// /// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use /// this bitmap to show a full-sized preview of a window or tab. /// /// A handle to the window. This window must belong to the calling process. /// A handle to the bitmap to represent the window that hwnd specifies. /// /// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This /// offset enables the tab window's contents to be drawn correctly in a live preview when it is drawn without its frame. /// /// The display options for the live preview. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, HBITMAP hbmp, [Optional] IntPtr pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags); /// /// Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation. The taskbar can use this bitmap as a /// thumbnail switch target for the window or tab. /// /// A handle to the window. This window must belong to the calling process. /// A handle to the bitmap to represent the window that hwnd specifies. /// The display options for the live preview. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmSetIconicThumbnail(HWND hwnd, HBITMAP hbmp, DWM_SETICONICPREVIEW_Flags dwSITFlags); /// Sets the value of non-client rendering attributes for a window. /// The handle to the window that will receive the attributes. /// /// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter /// points to the value of that attribute. /// /// /// A pointer to the value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require /// different value types. /// /// The size, in bytes, of the value type pointed to by the pvAttribute parameter. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [System.Security.SecurityCritical] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmSetWindowAttribute(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] IntPtr pvAttribute, int cbAttribute); /// Sets the value of non-client rendering attributes for a window. /// The handle to the window that will receive the attributes. /// /// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter /// points to the value of that attribute. /// /// /// The value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [PInvokeData("dwmapi.h")] public static HRESULT DwmSetWindowAttribute(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] T? pvAttribute) { if (pvAttribute == null || !CorrespondingTypeAttribute.CanSet(dwAttribute, typeof(T))) throw new ArgumentException(); var attr = pvAttribute is bool ? Convert.ToUInt32(pvAttribute) : (pvAttribute.GetType().IsEnum ? Convert.ChangeType(pvAttribute, Enum.GetUnderlyingType(pvAttribute.GetType())) : pvAttribute); using var p = new PinnedObject(attr); return DwmSetWindowAttribute(hwnd, dwAttribute, p, Marshal.SizeOf(attr)); } /// /// Called by an app or framework to specify the visual feedback type to draw in response to a particular touch or pen contact. /// /// The pointer ID of the contact. Each touch or pen contact is given a unique ID when it is detected. /// One or more of the following DWM_SHOWCONTACT visualizations that DWM should show for this contact. /// /// If dwPointerID does not match that of a contact currently present on the screen, this function returns E_INVALIDARG; otherwise, /// it returns S_OK. /// // DWMAPI DwmShowContact( DWORD dwPointerID, DWM_SHOWCONTACT eShowContact); https://msdn.microsoft.com/en-us/library/windows/desktop/hh706496(v=vs.85).aspx [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("Dwmapi.h", MSDNShortId = "hh706496")] public static extern HRESULT DwmShowContact(uint dwPointerID, DWM_SHOWCONTACT eShowContact); /// Enables the graphical feedback of touch and drag interactions to the user. /// The pointer ID. /// Indicates whether the contact is enabled. /// The tether. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmTetherContact(uint dwPointerID, [MarshalAs(UnmanagedType.Bool)] bool fEnable, POINT ptTether); /// Coordinates the animations of tool windows with the Desktop Window Manager (DWM). /// Handle to the window. /// The target. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmTransitionOwnedWindow(HWND hwnd, DWMTRANSITION_OWNEDWINDOW_TARGET target); /// Removes a Desktop Window Manager (DWM) thumbnail relationship created by the DwmRegisterThumbnail function. /// /// The handle to the thumbnail relationship to be removed. Null or non-existent handles will result in a return value of E_INVALIDARG. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h")] public static extern HRESULT DwmUnregisterThumbnail(HTHUMBNAIL hThumbnailId); /// /// Updates the properties for a Desktop Window Manager (DWM) thumbnail. /// /// /// /// The handle to the DWM thumbnail to be updated. Null or invalid thumbnails, as well as thumbnails owned by other processes will /// result in a return value of E_INVALIDARG. /// /// /// /// A pointer to a DWM_THUMBNAIL_PROPERTIES structure that contains the new thumbnail properties. /// /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// Thumbnail relationships created by the DwmRegisterThumbnail function will not be rendered to the destination window until this /// function is called. Subsequent calls will update the thumbnail according to the provided properties. /// /// Examples /// The following example demonstrates how to register and display the desktop thumbnail. /// // https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmupdatethumbnailproperties DWMAPI // DwmUpdateThumbnailProperties( HTHUMBNAIL hThumbnailId, const DWM_THUMBNAIL_PROPERTIES *ptnProperties ); [DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)] [PInvokeData("dwmapi.h", MSDNShortId = "dwmupdatethumbnailproperties")] public static extern HRESULT DwmUpdateThumbnailProperties(HTHUMBNAIL hThumbnailId, in DWM_THUMBNAIL_PROPERTIES ptnProperties); /// Specifies Desktop Window Manager (DWM) blur-behind properties. Used by the DwmEnableBlurBehindWindow function. [StructLayout(LayoutKind.Sequential)] [PInvokeData("dwmapi.h")] public struct DWM_BLURBEHIND { /// /// A bitwise combination of DWM Blur Behind constant values that indicates which of the members of this structure have been set. /// public DWM_BLURBEHIND_Mask dwFlags; /// TRUE to register the window handle to DWM blur behind; FALSE to unregister the window handle from DWM blur behind. [MarshalAs(UnmanagedType.Bool)] public bool fEnable; /// /// The region within the client area where the blur behind will be applied. A NULL value will apply the blur behind the entire /// client area. /// public HRGN hRgnBlur; /// TRUE if the window's colorization should transition to match the maximized windows; otherwise, FALSE. [MarshalAs(UnmanagedType.Bool)] public bool fTransitionOnMaximized; /// Initializes a new instance of the struct. /// if set to true enabled. public DWM_BLURBEHIND(bool enabled) { fEnable = enabled; hRgnBlur = IntPtr.Zero; fTransitionOnMaximized = false; dwFlags = DWM_BLURBEHIND_Mask.DWM_BB_ENABLE; } /// Gets or sets a value indicating whether the window's colorization should transition to match the maximized windows. /// true if the window's colorization should transition to match the maximized windows; otherwise, false. public bool TransitionOnMaximized { get => fTransitionOnMaximized; set { fTransitionOnMaximized = value; dwFlags |= DWM_BLURBEHIND_Mask.DWM_BB_TRANSITIONONMAXIMIZED; } } #if SYSDRAW /// Sets the region. /// The graphics. /// The region. public void SetRegion(Graphics graphics, Region region) { hRgnBlur = region.GetHrgn(graphics); dwFlags |= DWM_BLURBEHIND_Mask.DWM_BB_BLURREGION; } #endif } /// Structure to get colorization information using the function. [StructLayout(LayoutKind.Sequential)] [PInvokeData("dwmapi.h")] public struct DWM_COLORIZATION_PARAMS { /// The ARGB accent color. public RGBQUAD clrColor; /// The ARGB after glow color. public RGBQUAD clrAfterGlow; /// Determines how much the glass streaks are visible in window borders. public uint nIntensity; /// Determines how bright the glass is (0 removes all color from borders). public RGBQUAD clrAfterGlowBalance; /// Determines how bright the blur is. public RGBQUAD clrBlurBalance; /// Determines how much the glass reflection is visible. public RGBQUAD clrGlassReflectionIntensity; /// Determines if borders are opaque ( true) or transparent ( false). [MarshalAs(UnmanagedType.Bool)] public bool fOpaque; } /// Specifies Desktop Window Manager (DWM) thumbnail properties. Used by the DwmUpdateThumbnailProperties function. // typedef struct _DWM_THUMBNAIL_PROPERTIES { DWORD dwFlags; RECT rcDestination; RECT rcSource; BYTE opacity; BOOL fVisible; BOOL // fSourceClientAreaOnly;} DWM_THUMBNAIL_PROPERTIES, *PDWM_THUMBNAIL_PROPERTIES; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969502(v=vs.85).aspx [PInvokeData("Dwmapi.h", MSDNShortId = "aa969502")] [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct DWM_THUMBNAIL_PROPERTIES { /// A bitwise combination of DWM thumbnail constant values that indicates which members of this structure are set. public DWM_TNP dwFlags; /// The area in the destination window where the thumbnail will be rendered. public RECT rcDestination; /// The region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail. public RECT rcSource; /// /// The opacity with which to render the thumbnail. 0 is fully transparent while 255 is fully opaque. The default value is 255. /// public byte opacity; /// TRUE to make the thumbnail visible; otherwise, FALSE. The default is FALSE. [MarshalAs(UnmanagedType.Bool)] public bool fVisible; /// TRUE to use only the thumbnail source's client area; otherwise, FALSE. The default is FALSE. [MarshalAs(UnmanagedType.Bool)] public bool fSourceClientAreaOnly; } /// Specifies Desktop Window Manager (DWM) composition timing information. Used by the DwmGetCompositionTimingInfo function. [StructLayout(LayoutKind.Sequential, Pack = 1)] [PInvokeData("dwmapi.h")] public struct DWM_TIMING_INFO { /// The size of this DWM_TIMING_INFO structure. public int cbSize; /// The monitor refresh rate. public UNSIGNED_RATIO rateRefresh; /// The monitor refresh period. public ulong qpcRefreshPeriod; /// The composition rate. public UNSIGNED_RATIO rateCompose; /// The query performance counter value before the vertical blank. public ulong qpcVBlank; /// The DWM refresh counter. public ulong cRefresh; /// The DirectX refresh counter. public uint cDXRefresh; /// The query performance counter value for a frame composition. public ulong qpcCompose; /// The frame number that was composed at qpcCompose. public ulong cFrame; /// The DirectX present number used to identify rendering frames. public uint cDXPresent; /// The refresh count of the frame that was composed at qpcCompose. public ulong cRefreshFrame; /// The DWM frame number that was last submitted. public ulong cFrameSubmitted; /// The DirectX present number that was last submitted. public uint cDXPresentSubmitted; /// The DWM frame number that was last confirmed as presented. public ulong cFrameConfirmed; /// The DirectX present number that was last confirmed as presented. public uint cDXPresentConfirmed; /// The target refresh count of the last frame confirmed as completed by the GPU. public ulong cRefreshConfirmed; /// The DirectX refresh count when the frame was confirmed as presented. public uint cDXRefreshConfirmed; /// The number of frames the DWM presented late. public ulong cFramesLate; /// The number of composition frames that have been issued but have not been confirmed as completed. public uint cFramesOutstanding; /// The last frame displayed. public ulong cFrameDisplayed; /// The QPC time of the composition pass when the frame was displayed. public ulong qpcFrameDisplayed; /// The vertical refresh count when the frame should have become visible. public ulong cRefreshFrameDisplayed; /// The ID of the last frame marked as completed. public ulong cFrameComplete; /// The QPC time when the last frame was marked as completed. public ulong qpcFrameComplete; /// The ID of the last frame marked as pending. public ulong cFramePending; /// The QPC time when the last frame was marked as pending. public ulong qpcFramePending; /// /// The number of unique frames displayed. This value is valid only after a second call to the DwmGetCompositionTimingInfo function. /// public ulong cFramesDisplayed; /// The number of new completed frames that have been received. public ulong cFramesComplete; /// The number of new frames submitted to DirectX but not yet completed. public ulong cFramesPending; /// /// The number of frames available but not displayed, used, or dropped. This value is valid only after a second call to DwmGetCompositionTimingInfo. /// public ulong cFramesAvailable; /// /// The number of rendered frames that were never displayed because composition occurred too late. This value is valid only after /// a second call to DwmGetCompositionTimingInfo. /// public ulong cFramesDropped; /// The number of times an old frame was composed when a new frame should have been used but was not available. public ulong cFramesMissed; /// The frame count at which the next frame is scheduled to be displayed. public ulong cRefreshNextDisplayed; /// The frame count at which the next DirectX present is scheduled to be displayed. public ulong cRefreshNextPresented; /// /// The total number of refreshes that have been displayed for the application since the DwmSetPresentParameters function was /// last called. /// public ulong cRefreshesDisplayed; /// /// The total number of refreshes that have been presented by the application since DwmSetPresentParameters was last called. /// public ulong cRefreshesPresented; /// The refresh number when content for this window started to be displayed. public ulong cRefreshStarted; /// The total number of pixels DirectX redirected to the DWM. public ulong cPixelsReceived; /// The number of pixels drawn. public ulong cPixelsDrawn; /// The number of empty buffers in the flip chain. public ulong cBuffersEmpty; } /// Returned by the GetThemeMargins function to define the margins of windows that have visual styles applied. [StructLayout(LayoutKind.Sequential)] [PInvokeData("dwmapi.h")] public struct MARGINS { /// Width of the left border that retains its size. public int cxLeftWidth; /// Width of the right border that retains its size. public int cxRightWidth; /// Height of the top border that retains its size. public int cyTopHeight; /// Height of the bottom border that retains its size. public int cyBottomHeight; /// Retrieves a instance with all values set to 0. public static readonly MARGINS Empty = new(0); /// Retrieves a instance with all values set to -1. public static readonly MARGINS Infinite = new(-1); /// Initializes a new instance of the struct. /// The left border value. /// The right border value. /// The top border value. /// The bottom border value. public MARGINS(int left, int right, int top, int bottom) { cxLeftWidth = left; cxRightWidth = right; cyTopHeight = top; cyBottomHeight = bottom; } /// Initializes a new instance of the struct. /// Value to assign to all margins. public MARGINS(int allMargins) => cxLeftWidth = cxRightWidth = cyTopHeight = cyBottomHeight = allMargins; /// Gets or sets the left border value. /// The left border. public int Left { get => cxLeftWidth; set => cxLeftWidth = value; } /// Gets or sets the right border value. /// The right border. public int Right { get => cxRightWidth; set => cxRightWidth = value; } /// Gets or sets the top border value. /// The top border. public int Top { get => cyTopHeight; set => cyTopHeight = value; } /// Gets or sets the bottom border value. /// The bottom border. public int Bottom { get => cyBottomHeight; set => cyBottomHeight = value; } /// Determines if two values are not equal. /// The first margin. /// The second margin. /// true if the values are unequal; false otherwise. public static bool operator !=(MARGINS m1, MARGINS m2) => !m1.Equals(m2); /// Determines if two values are equal. /// The first margin. /// The second margin. /// true if the values are equal; false otherwise. public static bool operator ==(MARGINS m1, MARGINS m2) => m1.Equals(m2); /// Determines whether the specified , is equal to this instance. /// The to compare with this instance. /// true if the specified is equal to this instance; otherwise, false. public override bool Equals(object? obj) => obj is MARGINS m2 ? cxLeftWidth == m2.cxLeftWidth && cxRightWidth == m2.cxRightWidth && cyTopHeight == m2.cyTopHeight && cyBottomHeight == m2.cyBottomHeight : base.Equals(obj); /// Returns a hash code for this instance. /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { int RotateLeft(int value, int nBits) { nBits %= 0x20; return (value << nBits) | (value >> (0x20 - nBits)); } return cxLeftWidth ^ RotateLeft(cyTopHeight, 8) ^ RotateLeft(cxRightWidth, 0x10) ^ RotateLeft(cyBottomHeight, 0x18); } /// Returns a that represents this instance. /// A that represents this instance. public override string ToString() => $"{{Left={cxLeftWidth},Right={cxRightWidth},Top={cyTopHeight},Bottom={cyBottomHeight}}}"; } /// /// Defines a data type used by the Desktop Window Manager (DWM) APIs. It represents a generic ratio and is used for different /// purposes and units even within a single API. /// [StructLayout(LayoutKind.Sequential)] [PInvokeData("dwmapi.h")] public struct UNSIGNED_RATIO { /// The ratio numerator. public uint uiNumerator; /// The ratio denominator. public uint uiDenominator; } }