Jump to content

Recommended Posts

Posted

OK so it look like using:

ConsoleWrite("imagelist size (with dpi): " & _GUIImageList_GetIconHeight($hImageListLV) & @CRLF)

Works perfectly (before I wipe out the ImageList). So I can use that to get the proper size before creating the checkboxes from the theme. When I change the scaling on my system, the value from this changes correctly as well and it gives the precise size everytime. So this will do the job.

I don't think I will even need the Switch Case at all for this. This will be accurate, regardless of DPI and such. I'll put together another release in a few hours.

Posted

If you use scite can you tidies all files (Ctrl-T)?

your include files does not respect standard var naming i.e. Global $iDPi must be Global $g_iDpi

Anyway you are doing a fantastic Job

Cheers

Posted (edited)
7 hours ago, WildByDesign said:
9 hours ago, argumentum said:

..or continue sharpening your graphics using Bas64 😒

No way. 😁

I joke around but am mostly serious, in a not OMG! way ;)

7 hours ago, WildByDesign said:

This is a smart idea. Thank you. Especially good while trying to get this all figured out.

Does it do ConsoleWrite only in the case of error?

I assume that is the case because mine is not showing any output from it. But maybe that is because it is working properly on my system.

If you took the time to understand what you're reading, then what is presented is functional.
That debug thingy I gave you is to use everywhere but it can be annoying so by default will not consoleWrite unless !, you say "yes please show me"  ( via _GUIDarkThemeDebugOnOff(1) ).
So that when someone has a problem, the forum is not a chatter box of confusion because there was no proper debugging in place.
So again, copy'n'paste is great, if you follow the code and understand what it does and how.

And like JPM said: you are doing a fantastic Job. It looks good at 175% scale :)

P.S.: Here are the functions as you thought it would be:

< Removed the code. It was wrong. New fixed version here >

that way it will not echo unless there is an error but you can choose either or with:

#include "GUIDarkTheme.au3"
_GUIDarkThemeDebugOnOff(False, True) ; default state of the _GUIDarkThemeDebug() function

... mic. drop 🎤

Edited by argumentum
the keyboard is tired of me and won't obey my thoughts

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

Posted
2 hours ago, argumentum said:

P.S.: Here are the functions as you thought it would be:

I'm starting to wonder if this only works in SciTE and not VSCodium. I spent about 20 minutes with the first debug functions earlier and about the same now and I haven't seen a single ConsoleWrite.

I have the functions placed at the bottom of GUIDarkTheme.au3 UDF as you suggested earlier and the function to enable it in the example script, right after the #include "GUIDarkTheme.au3" line. I even tried switching them both to True like _GUIDarkThemeDebugOnOff(True, True) but no luck.

Actually I just decided to try SciTE right now while typing this up but it doesn't do anything either. I apologize but I have no idea how to make this do its thing.

Posted (edited)

the line "ElseIf $bTrueFalse Then ; ForceOnError ON" was wrong.

;~ #include "GUIDarkTheme.au3"
_GUIDarkThemeDebugOnOff(False, True) ; default state of the _GUIDarkThemeDebug() function

Global $sRet = TheWayOfMyErrors(0, "No error, no default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)
$sRet = TheWayOfMyErrors(1, "An error, default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)

Func TheWayOfMyErrors($iError, $sText)
    Return SetError($iError, 0, $sText)
EndFunc   ;==>TheWayOfMyErrors

Func _GUIDarkThemeDebugOnOff($bTrueFalse = Default, $bForceOnError = Default)
    Local $iExt = _GUIDarkThemeDebug("", "", 0, 0, -20)
    Local $iRet = _GUIDarkThemeDebug("", "", 0, 0, -10)

    If IsKeyword($bTrueFalse) Then ; return state
    ElseIf $bTrueFalse Then ; debug ON
        _GUIDarkThemeDebug("", "", 0, 0, -12)
        $iRet = True
    Else ; debug OFF
        _GUIDarkThemeDebug("", "", 0, 0, -11)
        $iRet = False
    EndIf

    If IsKeyword($bForceOnError) Then ; return state
    ElseIf $bForceOnError Then ; ForceOnError ON
        _GUIDarkThemeDebug("", "", 0, 0, -22)
        $iExt = 1
    Else ; ForceOnError OFF
        _GUIDarkThemeDebug("", "", 0, 0, -21)
        $iExt = 0
    EndIf

    Return SetError(0, $iExt, $iRet) ; Extended = $bForceOnError ; $iRet = $bDebug ;
    ; should I have used a bitwise operation 🤔
EndFunc   ;==>_GUIDarkThemeDebugOnOff

Func _GUIDarkThemeDebug($sStr, $sScript = '"GUIDarkTheme.au3"', $iErr = @error, $iExt = @extended, $iLine = @ScriptLineNumber)
    Local Static $bDebug = False, $bForceOnError = True
    Switch $iLine
        Case -10
            Return $bDebug
        Case -11
            $bDebug = False
            Return $bDebug
        Case -12
            $bDebug = True
            Return $bDebug
        Case -20
            Return $bForceOnError
        Case -21
            $bForceOnError = False
            Return $bForceOnError
        Case -22
            $bForceOnError = True
            Return $bForceOnError
    EndSwitch

    If ((Not $bDebug) And (Not $bForceOnError)) Then Return SetError($iErr, $iExt, 0)
    If ((Not $bDebug) And $bForceOnError And (Not $iErr)) Then Return SetError($iErr, $iExt, 0)
    Local $iRet = ConsoleWrite($sScript & '(' & $iLine & ') : ' & $iErr & '/' & $iExt & ' - ' & $sStr)
    Return SetError($iErr, $iExt, $iRet)
EndFunc   ;==>_GUIDarkThemeDebug

P.S.: There is an "Alt-D" in SciTE too ( try it while the cursor in on a variable ). But I think this is better for general distribution.
 

Edited by argumentum

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

Posted
5 hours ago, jpm said:

If you use scite can you tidies all files (Ctrl-T)?

your include files does not respect standard var naming i.e. Global $iDPi must be Global $g_iDpi

Anyway you are doing a fantastic Job

Thank you, I appreciate that. Yes, I will make these changes.

Posted (edited)
4 hours ago, WildByDesign said:

This is working good now. Thank you. :)

;~ #include "GUIDarkTheme.au3"

; default state of the _GUIDarkThemeDebug() function
ConsoleWrite('+ $bDebug = ' & _GUIDarkThemeDebugOnOff(False, True) & @TAB & ' $bForceOnError = ' & Not Not @extended & @CRLF)

Global $sRet = TheWayOfMyErrors(0, "No error, no default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)
$sRet = TheWayOfMyErrors(1, "An error, default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)

Func TheWayOfMyErrors($iError, $sText)
    Return SetError($iError, 0, $sText)
EndFunc   ;==>TheWayOfMyErrors

Func _GUIDarkThemeDebugOnOff($bDebug = Default, $bForceOnError = Default)
    Local $iVal = _GUIDarkThemeDebug("", "", "", "", -30 - BitOR(($bDebug ? 1 : 0), ($bForceOnError ? 2 : 0)))
    Return SetError(0, (BitAND($iVal, 2) ? 1 : 0), Not Not BitAND($iVal, 1))
EndFunc   ;==>_GUIDarkThemeDebugOnOff

Func _GUIDarkThemeDebug($sStr, $sScript = '"GUIDarkTheme.au3"', $iErr = @error, $iExt = @extended, $iLine = @ScriptLineNumber)
    Local Static $bDebug = False, $bForceOnError = True
    If $iErr == "" And $iLine <= -30 Then
        $bDebug = Not Not BitAND(30 - $iLine, 1)
        $bForceOnError = Not Not BitAND(30 - $iLine, 2)
        Return BitOR(($bDebug ? 1 : 0), ($bForceOnError ? 2 : 0))
    EndIf
    If ((Not $bDebug) And (Not $bForceOnError)) Then Return SetError($iErr, $iExt, 0)
    If ((Not $bDebug) And $bForceOnError And (Not $iErr)) Then Return SetError($iErr, $iExt, 0)
    Local $iRet = ConsoleWrite($sScript & '(' & $iLine & ') : ' & $iErr & '/' & $iExt & ' - ' & $sStr)
    Return SetError($iErr, $iExt, $iRet)
EndFunc   ;==>_GUIDarkThemeDebug

...now with Bitwise power (r)(tm)

Spoiler

..moww powwo :D
 

Global $__g_GUIDarkThemeDebugScriptName = '"GUIDarkTheme.au3"' ; somewhere on top of some script

;~ #include "GUIDarkTheme.au3"

; default state of the _GUIDarkThemeDebug() function
ConsoleWrite('+ DebugOnOff = ' & _GUIDarkThemeDebugOnOff(False, True, False) & @CRLF)

Global $sRet = TheWayOfMyErrors(0, 0, "No error, no default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)
$sRet = TheWayOfMyErrors(1, 0, "An error, default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)
$sRet = TheWayOfMyErrors(0, 1, "Extended info, no default ""echo""")
_GUIDarkThemeDebug($sRet & @CRLF)

Func TheWayOfMyErrors($iError, $iExtended, $sText)
    Return SetError($iError, $iExtended, $sText)
EndFunc   ;==>TheWayOfMyErrors

Func _GUIDarkThemeDebugScriptName($sStr = Default)
    If Not IsKeyword($sStr) Then $__g_GUIDarkThemeDebugScriptName = '"' & StringReplace($sStr, '"', '') & '"'
    Return $__g_GUIDarkThemeDebugScriptName
EndFunc   ;==>_GUIDarkThemeDebugScriptName

Func _GUIDarkThemeDebugOnOff($bDebug = Default, $bForceOnError = Default, $bForceOnExtended = Default)
    Local $iVal = _GUIDarkThemeDebug("", "", "", "", -10 - BitOR(($bDebug ? 1 : 0), ($bForceOnError ? 2 : 0), ($bForceOnExtended ? 4 : 0)))
    Return SetError(0, $iVal, $iVal)
EndFunc   ;==>_GUIDarkThemeDebugOnOff

Func _GUIDarkThemeDebug($sStr, $sScript = $__g_GUIDarkThemeDebugScriptName, $iErr = @error, $iExt = @extended, $iLine = @ScriptLineNumber)
    Local Static $bDebug = False, $bForceOnError = True, $bForceOnExtended = False
    If $iErr == "" And $iLine <= -10 Then
        Local $iConfig = Abs($iLine + 10)
        $bDebug = BitAND($iConfig, 1)
        $bForceOnError = BitAND($iConfig, 2)
        $bForceOnExtended = BitAND($iConfig, 4)
        Return $iConfig
    EndIf
    If Not $bDebug Then
        If Not (($bForceOnError And $iErr <> 0) Or ($bForceOnExtended And $iExt <> 0)) Then Return SetError($iErr, $iExt, 0)
    EndIf
    Local $iRet = ConsoleWrite($sScript & '(' & $iLine & ') : ' & $iErr & '/' & $iExt & ' - ' & $sStr)
    Return SetError($iErr, $iExt, $iRet)
EndFunc   ;==>_GUIDarkThemeDebug

 

 

Edited by argumentum
oops

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

Posted
44 minutes ago, bladem2003 said:

Is dark mode checkbox only for Windows 11?

I just checked the theme resources available on Windows 10 right now because I wasn't sure. They do have an entry for DarkMode_Explorer::Button, but the resource for CHECKBOX is blank, meaning that they don't have the dark mode resources for it. In that case, they would use the light mode resource.

Do you need it?

If you need it for a project or something, I can add it back for you.

I assume that the regular checkbox (from the button control) is light mode as well. I don't know how to change that one though.

Posted
18 minutes ago, bladem2003 said:

Couldn't both be implemented, and if Windows = 10, then use the icons with base64 encoding?

Yes, for sure. That’s a good idea.

The only problem is that my attempts to use Base64 encoded png images all failed. I can use the png images successfully, but my Base64 code all failed. I would need someone that can help me with that.

Posted
On 3/5/2026 at 9:07 AM, argumentum said:

 

...
        $iDPI = __WinAPI_GetDpiForWindow($hGUI)
        ConsoleWrite('"GUIDarkTheme.au3"(' & @ScriptLineNumber & ') : $iDPI = ' & $iDPI & @CRLF)
        Switch $iDPI
            Case 96
                $iSize = 13
            Case 120
                $iSize = 16
            Case 144, 168
                $iSize = 20
...
"GUIDarkTheme.au3"(1888) : $iDPI = 0
"GUIDarkTheme.au3"(1858) : $iDPI = 0

 

I forgot to ask you about this. I assume that it means the GetDpiForWindow function is failing on your system. This is important for me to figure this problem out because I rely on that function a lot. And if it fails for a certain percentage of users, that is not good.

Could it be that your OS is Server?

I may have to use another method to get DPI.

Posted (edited)

The __WinAPI_GetDpiForWindow function seems to be working.
I'm getting different values at different DPI settings.
My system is Windows 10 LTSC.

 

; TODO: these functions probably need common #FUNCTION# to be more descriptive
Func _ApplyDarkTheme($hGUI, $bPreferNewTheme = False)
    $iDPI2 = __WinAPI_GetDpiForWindow($hGUI)
    
    MsgBox(0,"", $iDPI2) ; 100% = 96,  150% = 144   <----------------------
    
    If @error Then $iDPI2 = 96
    _GUISetDarkTheme($hGUI, True)
    _GUICtrlAllSetDarkTheme($hGUI, True, $bPreferNewTheme)

    ; GUIDarkMenu
    _GUITopMenuTheme($hGUI)
    ; redraw menus
    _GUICtrlMenu_DrawMenuBar($hGUI)
EndFunc

 

Edited by bladem2003
Posted (edited)
31 minutes ago, WildByDesign said:

Yes, for sure. That’s a good idea.

The only problem is that my attempts to use Base64 encoded png images all failed. I can use the png images successfully, but my Base64 code all failed. I would need someone that can help me with that.

 

You can put the PNGs in the temp folder and load them from there.
I've attached an example.

 

This example uses your icons from an earlier version

 

CheckIcons.au3

Edited by bladem2003
Posted

I am working on the statusbar detection and subclassing right now. As always, my goal is to make it detect the specific control and subclass only if necessary. So I made a function that will detect a statusbar from any GUI script, pull in the parts to store the text, switch the parts/text to OWNERDRAW automatically and then move on to the subclassing. No extra effort by the person using the UDF.

You can see the current progress in a screenshot here but there is some more work to do to look nicer. I need to probably wait for @pixelsearch to help me with some of the problems with my new approach to it using the DrawThemeBackground for the sizegrip.

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