Decibel Posted October 30, 2024 Posted October 30, 2024 (edited) This isn't a big deal to me, but I noticed this and am curious how APIGdiConstants.au3 could still work when the MS docs show a different enum value. I'm running AutoIt 3.3.16.1 on Win11 x64. APIGdiConstants.au3 has the following lines (75-87) that sets the first enum $DWMWA_NCRENDERING_ENABLED = 1: ; _WinAPI_DwmGetWindowAttribute(), _WinAPI_DwmSetWindowAttribute() Global Const $DWMWA_NCRENDERING_ENABLED = 1 Global Const $DWMWA_NCRENDERING_POLICY = 2 Global Const $DWMWA_TRANSITIONS_FORCEDISABLED = 3 Global Const $DWMWA_ALLOW_NCPAINT = 4 Global Const $DWMWA_CAPTION_BUTTON_BOUNDS = 5 Global Const $DWMWA_NONCLIENT_RTL_LAYOUT = 6 Global Const $DWMWA_FORCE_ICONIC_REPRESENTATION = 7 Global Const $DWMWA_FLIP3D_POLICY = 8 Global Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 Global Const $DWMWA_HAS_ICONIC_BITMAP = 10 Global Const $DWMWA_DISALLOW_PEEK = 11 Global Const $DWMWA_EXCLUDED_FROM_PEEK = 12 Microsoft (dated 07/10/2023) has the following Syntax that I assume is starting at zero, setting DWMWA_NCRENDERING_ENABLED = 0 typedef enum DWMWINDOWATTRIBUTE { DWMWA_NCRENDERING_ENABLED, DWMWA_NCRENDERING_POLICY, DWMWA_TRANSITIONS_FORCEDISABLED, DWMWA_ALLOW_NCPAINT, DWMWA_CAPTION_BUTTON_BOUNDS, DWMWA_NONCLIENT_RTL_LAYOUT, DWMWA_FORCE_ICONIC_REPRESENTATION, DWMWA_FLIP3D_POLICY, DWMWA_EXTENDED_FRAME_BOUNDS, DWMWA_HAS_ICONIC_BITMAP, DWMWA_DISALLOW_PEEK, DWMWA_EXCLUDED_FROM_PEEK, DWMWA_CLOAK, DWMWA_CLOAKED, DWMWA_FREEZE_REPRESENTATION, DWMWA_PASSIVE_UPDATE_MODE, DWMWA_USE_HOSTBACKDROPBRUSH, DWMWA_USE_IMMERSIVE_DARK_MODE = 20, DWMWA_WINDOW_CORNER_PREFERENCE = 33, DWMWA_BORDER_COLOR, DWMWA_CAPTION_COLOR, DWMWA_TEXT_COLOR, DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_LAST } ; What really throws me is that the APIGdiConstants.au3 lines just below the set above (89-91) do correlate to what Microsoft says and they work as expected: Global Const $DWMNCRP_USEWINDOWSTYLE = 0 Global Const $DWMNCRP_DISABLED = 1 Global Const $DWMNCRP_ENABLED = 2 Microsoft (dated 02/22/2024): typedef enum DWMNCRENDERINGPOLICY { DWMNCRP_USEWINDOWSTYLE, DWMNCRP_DISABLED, DWMNCRP_ENABLED, DWMNCRP_LAST } ; AutoIt Code Example: Opt("MustDeclareVars", 1);require variables to be declared #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> ;*** Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 400) ;*** Display the GUI. GUISetState(@SW_SHOW, $hGUI) ConsoleWrite("$DWMWA_NCRENDERING_POLICY: '" & $DWMWA_NCRENDERING_POLICY & "' (expecting 2, but MS says 1)" & @CRLF) ConsoleWrite("$DWMNCRP_DISABLED: '" & $DWMNCRP_DISABLED & "' (expecting 1 per AutoIt and MS)" & @CRLF) #Region - Uncomment the block for the scenario that you want to see ;*** Demonstrate that APIGdiConstants.au3 declaration of $DWMWA_NCRENDERING_POLICY = 2 instead of Microsoft's enum = 1 works ConsoleWrite("Before: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 1)" & @CRLF) _WinAPI_DwmSetWindowAttribute($hGUI, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) ConsoleWrite("After: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 0)" & @CRLF) ;~ ;*** Demonstrate that the value for APIGdiConstants.au3 declaration of $DWMWA_NCRENDERING_POLICY = 2 instead of Microsoft's enum = 1 works ;~ ConsoleWrite("Before: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 1)" & @CRLF) ;~ _WinAPI_DwmSetWindowAttribute($hGUI, 2, $DWMNCRP_DISABLED) ;~ ConsoleWrite("After: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 0)" & @CRLF) ;~ ;*** Demonstrate that Microsoft's enum = 1 does not work because APIGdiConstants.au3 has it mapped to $DWMWA_NCRENDERING_ENABLED ;~ ConsoleWrite("Before: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 1)" & @CRLF) ;~ _WinAPI_DwmSetWindowAttribute($hGUI, 1, $DWMNCRP_DISABLED) ;~ ConsoleWrite("After: '" & _WinAPI_DwmGetWindowAttribute ( $hGUI, $DWMWA_NCRENDERING_ENABLED ) & "' (expecting 0)" & @CRLF) #EndRegion - Uncomment the block for the scenario that you want to see ;*** Delete the previous GUI and all controls. GUIDelete($hGUI) Here is my online C++ attempt to understand/confirm how C++ enumerations work, and they seem to work exactly how I understand (I.e. start at 0 unless differently declared). Edit: This stemmed from an example about how to force rounded corners, of which I actually wanted the opposite, and achieved it from that code. Edited October 30, 2024 by Decibel
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now