Andy27 Posted September 8, 2022 Share Posted September 8, 2022 Hi I don't know if this is the right place for this but I thought it might come in useful to someone and I couldn't find it while I was searching for posts that address it. This: Global $exampleGUI = GUICreate("Rounded corners", 400, 300, -1, -1) Will automatically get rounded corners in Windows 11... But this: Global $exampleGUI = GUICreate("Rounded corners", 400, 300, -1, -1, $WS_POPUP) Will not. I usually like to ditch the windows title bar and replace it with my own, so it was annoying, that on Windows 11, my stuff didn't look the part. The trick is to use DwmSetWindowAttribute to set DWMWA_WINDOW_CORNER_PREFERENCE (33) to DWMWCP_ROUND (2) as explained here: Apply rounded corners in desktop apps for Windows 11 I modified the function in WinAPIGdi.au3 to accept 33 as a valid parameter and used the function from there: Func _WinAPI_DwmSetWindowAttribute($hWnd, $iAttribute, $iData) Switch $iAttribute Case 2, 3, 4, 6, 7, 8, 10, 11, 12, 33 Case Else Return SetError(1, 0, 0) EndSwitch Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _ 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then Return SetError(10, $aCall[0], 0) Return 1 EndFunc ;==>_WinAPI_DwmSetWindowAttribute Example: #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <Windowsconstants.au3> Global $exampleGUI = GUICreate("Rounded corners", 400, 300, -1, -1, $WS_POPUP) _WinAPI_DwmSetWindowAttribute($exampleGUI,33,2) Local $label = GUICtrlCreateLabel(" This is an example.", 50, 150,200, 50) GUISetState(@SW_SHOW, $exampleGUI) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Decibel, dmob, Shark007 and 1 other 4 Link to comment Share on other sites More sharing options...
Shark007 Posted September 20, 2022 Share Posted September 20, 2022 (edited) Since the post I was commenting on has been deleted . . . This post is no longer relevant. Edited September 21, 2022 by Shark007 Link to comment Share on other sites More sharing options...
taurus905 Posted February 22, 2023 Share Posted February 22, 2023 @Andy27 Do you know if "DwmSetWindowAttribute" can be used to change a single gui titlebar color and font color? Thank you. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
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