Function Reference


_WinAPI_DwmGetWindowAttribute

Retrieves the current value of a specified attribute applied to the window

#include <WinAPIGdi.au3>
_WinAPI_DwmGetWindowAttribute ( $hWnd, $iAttribute )

Parameters

$hWnd Handle to the window for which the attribute data is retrieved.
$iAttribute The attribute to retrieve. This parameter can be one of the following values:

Windows Vista or later
    $DWMWA_NCRENDERING_ENABLED (1)
        Discovers whether non-client rendering is enabled.
        Return a value of type BOOL.
        TRUE if non-client rendering is enabled; otherwise, FALSE.
    $DWMWA_TRANSITIONS_FORCEDISABLED (3)
        Enables or forcibly disables DWM transitions.
        Return a value of type BOOL.
        TRUE to disable transitions, or FALSE to enable transitions.
    $DWMWA_CAPTION_BUTTON_BOUNDS (5)
        Retrieves the bounds of the caption button area in the window-relative space.
        Return a $tRect structure. If the window is minimized or otherwise not visible to the user, then the value of the $tRect retrieved is undefined.
        You should check whether the retrieved RECT contains a boundary that you can work with, and if it doesn't then you can conclude that the window is minimized or otherwise not visible.
    $DWMWA_EXTENDED_FRAME_BOUNDS (9)
        Retrieves the extended frame bounds rectangle in screen space.
        Return a value of type RECT.

Windows 7 or later
    $DWMWA_CLOAKED (14)
        If the window is cloaked, provides one of the following values explaining why.
            DWM_CLOAKED_APP (value 0x00000001). The window was cloaked by its owner application.
            DWM_CLOAKED_SHELL (value 0x00000002). The window was cloaked by the Shell.
            DWM_CLOAKED_INHERITED (value 0x00000004). The cloak value was inherited from its owner window.

Windows 11 (@OSBuild = 22000) or later
    $DWMWA_VISIBLE_FRAME_BORDER_THICKNESS (37)
        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.
        Return a value of type UINT.

Windows 11 (@OSBuild = 22621) or later
        $WMWA_SYSTEMBACKDROP_TYPE (38)
            Retrieves the system-drawn backdrop material of a window, including behind the non-client area.
        Return a value of type DWM_SYSTEMBACKDROP_TYPE.
            $DWMSBT_AUTO
                The default. Let the Desktop Window Manager (DWM) automatically decide the system-drawn backdrop material for this window. This applies the backdrop material just behind the default Win32 title bar. This behavior attempts to preserve maximum backwards compatibility.
                For this reason, the DWM might also decide to draw no backdrop material at all based on internal heuristics.
                If drawing the backdrop material behind the entire window is required, choose one of the other more specific values of this enum as appropriate.
            $DWMSBT_NONE
                Don't draw any system backdrop.
            $DWMSBT_MAINWINDOW
                Draw the backdrop material effect corresponding to a long-lived window behind the entire window bounds.
                For Windows 11, this corresponds to Mica in its default variant. The material effect might change with future Windows releases. For more info about Mica, see Mica.
            $DWMSBT_TRANSIENTWINDOW
                Draw the backdrop material effect corresponding to a transient window behind the entire window bounds.
                For Windows 11, this corresponds to Desktop Acrylic, also known as Background Acrylic, in its brightest variant. The material effect might change with future Windows releases. For more info about Desktop Acrylic, see Acrylic.
            $DWMSBT_TABBEDWINDOW
                Draw the backdrop material effect corresponding to a window with a tabbed title bar behind the entire window bounds.
                For Windows 11, this corresponds to Mica in its alternate variant (Mica Alt).
                The material might change with future releases of Windows. For more info about Mica Alt, see Layering with Mica Alt.

Return Value

Success: The value that contains the current value of the attribute.
    The type of the returned value depends on the value of the $iAttribute parameter.
Failure: 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Related

_WinAPI_DwmSetWindowAttribute

See Also

Search DwmGetWindowAttribute in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Run(@SystemDir & '\calc.exe')
Local $hWnd = WinWaitActive("[CLASS:ApplicationFrameWindow]", '') ;, 3)
If Not $hWnd Then
    Exit
EndIf

Local $aPos = _WinAPI_GetPosFromRect(_WinAPI_DwmGetWindowAttribute($hWnd, $DWMWA_EXTENDED_FRAME_BOUNDS))

ConsoleWrite('Left:   ' & $aPos[0] & @CRLF)
ConsoleWrite('Top:    ' & $aPos[1] & @CRLF)
ConsoleWrite('Width:  ' & $aPos[2] & @CRLF)
ConsoleWrite('Height: ' & $aPos[3] & @CRLF)