Jump to content

Rounded corners on Windows 11


Recommended Posts



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.


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)

    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


#include <WinAPIGdi.au3>
#include <GUIConstantsEx.au3>
#include <Windowsconstants.au3>

Global $exampleGUI = GUICreate("Rounded corners", 400, 300, -1, -1, $WS_POPUP)

Local $label = GUICtrlCreateLabel(" This is an example.", 50, 150,200, 50)

GUISetState(@SW_SHOW, $exampleGUI)
While 1
$msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE


Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

@Andy27 Do you know if "DwmSetWindowAttribute" can be used to change a single gui titlebar color and font color?

Thank you.


"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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...