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