Jump to content

Recommended Posts

Posted

By the way, the text is measured with _WinAPI_GetTextExtentPoint32 which I assume does not take DPI into consideration. Although I am not 100% sure on that. I wonder if I need to apply the DPI math in that area which might be easier.

Posted
5 hours ago, argumentum said:

The menu drop down in SampleControls-Dark.au3 does not show dark as it did.

Just to confirm, when you click on Menu One in the menubar, the drop down is not in dark mode anymore?

Also if you have a moment, can you try it again right now?

I'm just curious if it is happening 100% of the time or if it's random. Either way, it's going to have to be fixed. Thanks for letting me know.

Posted (edited)
14 minutes ago, bladem2003 said:

I can confirm, the dropdown menu is not in dark mode.
I don't know if it's important, but my system is Windows 10 Pro.

This is interesting. Thanks for confirming. In my case with Windows 11 Pro, the top menus and context menu all work properly.

Did these menus show in dark mode for your before this last release?

The only thing that I can think of that I added (0.6 release) in the area of code which affects the main GUI was related to disabling the focus rectangle dots. But I think it might be worth trying to comment out that line to see if it makes a difference.

In the GUIDarkTheme.au3 file within the _GUISetDarkTheme function, can you please comment out the line below and test again?

_SendMessage($hWnd, $WM_CHANGEUISTATE, 65537, 0)

 

Edited by WildByDesign
Posted
1 hour ago, WildByDesign said:

This is interesting. Thanks for confirming. In my case with Windows 11 Pro, the top menus and context menu all work properly.

Did these menus show in dark mode for your before this last release?

The only thing that I can think of that I added (0.6 release) in the area of code which affects the main GUI was related to disabling the focus rectangle dots. But I think it might be worth trying to comment out that line to see if it makes a difference.

In the GUIDarkTheme.au3 file within the _GUISetDarkTheme function, can you please comment out the line below and test again?

_SendMessage($hWnd, $WM_CHANGEUISTATE, 65537, 0)

 

Yes, that works!!!

Posted
3 minutes ago, argumentum said:

WinMerge is a good tool to compare files.

That's a good suggestion, thanks. I actually diff files quite often using the diff comparison that is built into VSCodium. It does a really beautiful side-by-side comparison and highlights the additions with the typical green and removals in red. The minimap on the side also makes it easy to navigate the differences.

8 minutes ago, argumentum said:

Yes it was working before, hence the complain.

I broke it. Oops. 😁

Posted
2 minutes ago, bladem2003 said:

Yes, that works!!!

That is really weird. But thankfully that is an easy fix. It's weird how it only affects some systems.

I really dislike those focus rectangle dots on any of the controls. Before I get rid of it, can you please test one more thing?

Func _GUISetDarkTheme($hWnd, $bEnableDarkTheme = True)
    ; Disable rectangle focus dots around controls
    _SendMessage($hWnd, $WM_CHANGEUISTATE, 65537, 0)
    Local $iPreferredAppMode = ($bEnableDarkTheme == True) ? $APPMODE_FORCEDARK : $APPMODE_FORCELIGHT
    Local $iGUI_BkColor = ($bEnableDarkTheme == True) ? $GUIDARKMODE_COLOR_GUIBK : _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))
    _WinAPI_SetPreferredAppMode($iPreferredAppMode)
    _WinAPI_RefreshImmersiveColorPolicyState()
    _WinAPI_FlushMenuThemes()
    GUISetBkColor($iGUI_BkColor, $hWnd)
    _GUICtrlSetDarkTheme($hWnd, $bEnableDarkTheme)          ;To Color the GUI's own Scrollbar
;~  DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $DWMWA_USE_IMMERSIVE_DARK_MODE, 'dword*', Int($bEnableDarkTheme), 'dword', 4)
    _WinAPI_DwmSetWindowAttribute_unr($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, $bEnableDarkTheme)
EndFunc   ;==>_GUISetDarkTheme

 

I am wondering if we hit that _SendMessage function at the top of the function whether or not we can keep it and not have any negative effects.

Posted (edited)

Strange, now it works even without any changes.
I re-downloaded the file (GUIDarkTheme-0.6.7z) and ran it without making any changes.

Edited by bladem2003
Posted (edited)

GUIDarkTheme 0.7:

  • Removed approx. 80% unneeded code from GUIDarkMenu.au3 UDF
  • Improved overall performance of menubar coloring
  • Improved cleanup (on exit) in both GUIDarkTheme.au3 UDF and GUIDarkMenu.au3 UDF
  • Fixed issue with menus not always being dark mode on some systems 🤞🤞

@argumentum and @bladem2003 Can you please test to determine if the menu issue is fixed or not? Thanks :)

This should be a good release overall. I put a lot of work into code cleanup and organization. And performance as well because I am OCD about that stuff.

GUIDarkTheme-0.7.7z

Edited by WildByDesign
Posted

add this to all your scripts: #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
If needed, add these ( as an example ) : #forceref $hwnd, $iMsg, $wParam, $lParam

Then you fix all the scripts ( yours and/or inherited ).
Then start working on debugging, but not before that.

..argumentum walks away dropping the mouse on the floor as if it was a microphone.. :D

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
9 minutes ago, argumentum said:

add this to all your scripts: #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

I can do that. It should be a lot easier now too since I was able to get rid of much of the inherited baggage. As a matter of fact, I’m not even sure there is much of ModernMenuRaw left in there now. :)

10 minutes ago, argumentum said:

If needed, add these ( as an example ) : #forceref $hwnd, $iMsg, $wParam, $lParam

I have zero experience of understanding of #forceref so I’m not even sure which functions and such. I would need some help there I think.

12 minutes ago, argumentum said:

..argumentum walks away dropping the mouse on the floor as if it was a microphone.. :D

Mouse drop!!! 🐭 

Posted
12 minutes ago, WildByDesign said:

I have zero experience of understanding of #forceref

Jos made the SciTE and utilities, and is a godsend, because it'll show what could be a problem and often times is right.
So, as a default you add "#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7"

Once you run, or Ctrl-F5, the console will show a bunch of complains, of which some are of variables that are needed even if unused.
For those you add "#forceref $MyVar, $MyOtherVar" but only if is a must, like in a GUIRegisterMsg() function. Don't go around just overriding a complain.

If you use those, it'll train you to code better ;) 

Disclaimer: Some of the code you've inherited is mine and to my defense, ain't got one. Is just ugly. But "do as I say not as I do" :lol:  

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)
1 hour ago, argumentum said:

Ctrl-F5, the console will show a bunch of complains,

Spoiler
;********************************************************************
; WM_DRAWITEM procedure
;********************************************************************
Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $tagDRAWITEM = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;ptr hwndItem;handle hDC;" & _
            "long left;long top;long right;long bottom;ulong_ptr itemData"
    Local $t = DllStructCreate($tagDRAWITEM, $lParam)
    If Not IsDllStruct($t) Then Return $GUI_RUNDEFMSG

    If $t.CtlType <> $ODT_MENU Then Return $GUI_RUNDEFMSG

    Local $hDC = $t.hDC
    Local $left = $t.left
    Local $top = $t.top
    Local $right = $t.right
    Local $bottom = $t.bottom
    Local $state = $t.itemState
    Local $itemID = $t.itemID

    ; convert itemID to position
    Local $iPos = -1
    For $i = 0 To UBound($g_aMenuText) - 1
        If $itemID = $g_aMenuText[$i][0] Then
            $iPos = $i
            ExitLoop
        EndIf
    Next

    If $iPos < 0 Then $iPos = $itemID
    If $iPos < 0 Or $iPos >= UBound($g_aMenuText) Then $iPos = 0

    Local $sText = $g_aMenuText[$iPos][1]
    $sText = StringReplace($sText, "&", "")

    ; Colors
    Local $clrBG = _ColorToCOLORREF($COLOR_BG_DARK)
    Local $clrSel = _ColorToCOLORREF(0x505050)
    Local $clrText = _ColorToCOLORREF($COLOR_TEXT_LIGHT)

    Static $iDrawCount = 0
    Static $bFullBarDrawn = False

    ; Count how many items were drawn in this "draw cycle"
    $iDrawCount += 1

    ; argumentum ; pre-declare all the "Local" in those IF-THEN that could be needed
    Local $tClient, $iFullWidth, $tFullMenuBar, $hFullBrush
    Local $tEmptyArea, $hEmptyBrush

    ; If we are at the first item AND the bar has not yet been drawn
    If $iPos = 0 And Not $bFullBarDrawn Then
        ; Get the full window width
        $tClient = _WinAPI_GetClientRect($hWnd)
        $iFullWidth = $tClient.right

        ; Fill the entire menu bar
        $tFullMenuBar = DllStructCreate($tagRECT)
        With $tFullMenuBar
            .left = 0
            .top = $top - 1
            .right = $iFullWidth + 3
            .bottom = $bottom
        EndWith

        $hFullBrush = _WinAPI_CreateSolidBrush($clrBG)
        _WinAPI_FillRect($hDC, $tFullMenuBar, $hFullBrush)
        _WinAPI_DeleteObject($hFullBrush)
    EndIf

    ; After drawing all items, mark as "drawn"
    If $iDrawCount >= UBound($g_aMenuText) Then
        $bFullBarDrawn = True
        $iDrawCount = 0
    EndIf

    ; Draw background for the area AFTER the last menu item
    If $iPos = (UBound($g_aMenuText) - 1) Then ; Last menu
        $tClient = _WinAPI_GetClientRect($hWnd)
        $iFullWidth = $tClient.right

        ; Fill only the area to the RIGHT of the last menu item
        If $right < $iFullWidth Then
            $tEmptyArea = DllStructCreate($tagRECT)
            With $tEmptyArea
                .left = $right
                .top = $top ;        argumentum ; replace magic numbers with it's parameter name when possible
                .right = $iFullWidth + _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) ; 7 = $SM_CXDLGFRAME
                .bottom = $bottom
            EndWith

            $hEmptyBrush = _WinAPI_CreateSolidBrush($clrBG)
            _WinAPI_FillRect($hDC, $tEmptyArea, $hEmptyBrush)
            _WinAPI_DeleteObject($hEmptyBrush)
        EndIf
    EndIf

    ; Draw item background (selected = lighter)
    Local $bSelected = BitAND($state, $ODS_SELECTED)
    Local $bHot = BitAND($state, $ODS_HOTLIGHT)
    Local $hBrush

    If $bSelected Then
        $hBrush = _WinAPI_CreateSolidBrush($clrSel)
    ElseIf $bHot Then
        $hBrush = _WinAPI_CreateSolidBrush($COLOR_HOTTRACK_MENU)
    Else
        $hBrush = _WinAPI_CreateSolidBrush($clrBG)
    EndIf

    Local $tItemRect = DllStructCreate($tagRECT)
    With $tItemRect
        .left = $left
        .top = $top
        .right = $right
        .bottom = $bottom
    EndWith

    _WinAPI_FillRect($hDC, $tItemRect, $hBrush)
    _WinAPI_DeleteObject($hBrush)

    ; Setup font
    Local $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0)
    If Not $hFont Then $hFont = _WinAPI_GetStockObject($DEFAULT_GUI_FONT)
    Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont)

    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SetTextColor($hDC, $clrText)

    ; Draw text
    Local $tTextRect = DllStructCreate($tagRECT)
    With $tTextRect
        .left = $left + 10
        .top = $top + 4
        .right = $right - 10
        .bottom = $bottom - 4
    EndWith

    DllCall($hUser32Dll, "int", "DrawTextW", "handle", $hDC, "wstr", $sText, "int", -1, "ptr", _
            DllStructGetPtr($tTextRect), "uint", BitOR($DT_SINGLELINE, $DT_VCENTER, $DT_LEFT))

    If $hOldFont Then _WinAPI_SelectObject($hDC, $hOldFont)

    Return 1
EndFunc   ;==>WM_DRAWITEM

..from "GUIDarkMenu.au3"

I "fixed" this function as an example of how to go about it, because if you've never done it before, it could be a good example.

Edit: found name of magic number

Edited by argumentum
more

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...