Jump to content

Recommended Posts

Posted (edited)

This UDF was created within the DarkMode UDF for AutoIt's Win32GUIs thread which was originally created by @NoNameCode. I ended up extending the features quite significantly and therefore decided to branch off into a new thread because I do not want to take anything away from the original DarkMode UDF.

Goal:

My goal was to make everything as automated and as simple as possible. I wanted it so that whoever is using it can just add one line of code _GUIDarkTheme_ApplyDark($hGUI, True) just before their already existing GUISetState() function. This would initiate the dark mode and automatically detect all controls, convert to dark mode and use the necessary subclassing whenever needed.

Community:

This UDF contains a lot of code from throughout the amazing AutoIt community and therefore belongs to every single one of us. I am always welcome to any suggestions and collaboration.

 

Changelog:

Spoiler

GUIDarkTheme 1.2.0:

  • GUIDarkTheme and GUIDarkMenu have been combined
  • Added new function _GUIDarkTheme_ApplyMaterial() for applying Windows 11 materials (Mica, Acrylic, etc.)
    • SampleControls-ModernDark example has been updated to show material effect
    • Requires Windows 11 build 22621 or higher

GUIDarkTheme 1.2.1:

  • Add TVS_EX_DOUBLEBUFFER extended style to TreeView controls

 

GUIDarkTheme-1.2.0.7z

GUIDarkTheme-1.2.1.7z

Edited by WildByDesign
Posted

I haven’t seen it before, but I’m thinking maybe adding doublebuffer to the TreeView control should fix it. I can have that applied through the UDF.

I will post an update later with doublebuffer applied to see if it helps.

Posted

I cannot reproduce the artifact issue on my main system. I just uploaded version 1.2.1 which automatically adds TVS_EX_DOUBLEBUFFER to any TreeView controls.

Can you both please test it and see if it helps with this issue?

Posted (edited)

You can overpaint the size grips in edit, listvew and treeview.

I used in my example $WM_PAINT in _SubclassProc function:

...
        Case $WM_PAINT
            Local $sClass = StringLower(_WinAPI_GetClassName($hWnd))
            If $sClass = "syslistview32" Or $sClass = "systreeview32" Or $sClass = "edit" Then ; hide Sizegrip boxes
                Local $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)

                ; Overpaint sizegrip boxes if visible
                Local $iWinStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
                If BitAND($iWinStyle, $WS_HSCROLL) And BitAND($iWinStyle, $WS_VSCROLL) Then
                    Local $hDC = _WinAPI_GetWindowDC($hWnd) ; GetWindowDC statt GetDC!
                    Local $tWnd = _WinAPI_GetWindowRect($hWnd)
                    Local $tClient = _WinAPI_GetClientRect($hWnd)
                    Local $iScrollW = _WinAPI_GetSystemMetrics($SM_CXVSCROLL)
                    Local $iScrollH = _WinAPI_GetSystemMetrics($SM_CYHSCROLL)
                    
                    ; convert client-area to Window coordinates
                    Local $tPt = DllStructCreate($tagPOINT)
                    $tPt.X = $tClient.right
                    $tPt.Y = $tClient.bottom
                    DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPt)
                                    
                    ; direct relativ coordinates
                    Local $tCorner = DllStructCreate($tagRECT), $delta = (_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) And $WS_EX_CLIENTEDGE ? 4 : 1)
                    $tCorner.left   = $tClient.right  + $delta
                    $tCorner.top    = $tClient.bottom + $delta
                    $tCorner.right  = $tCorner.left + $iScrollW
                    $tCorner.bottom = $tCorner.top  + $iScrollH
                    
                    Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_TITLE_DARK))
                    _WinAPI_FillRect($hDC, $tCorner, $hBrush)
                    _WinAPI_DeleteObject($hBrush)
                    _WinAPI_ReleaseDC($hWnd, $hDC)
                EndIf
                Return $iRet
            Else
                Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
            EndIf
...

I didn't test it for DPI <> 1 aka 96 if $tCorner is properly calculated.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
×
×
  • Create New...