Jump to content

Recommended Posts

Posted
3 hours ago, WildByDesign said:

I notice that you quite often use StringLower in your switches when comparing class names in a few areas. Is this a choice specifically for improving performance of running through the switches?

It started with copy / paste and continued without the need of StringLower because string compare is not case sensitive in Autoit -> can be removed to improve performance.

3 hours ago, WildByDesign said:

Regarding window procedure functions. We can have many individual window procedure functions for different controls or we can have one big window procedure function for all subclassed controls. Would there be any difference in overall performance?

I would say use a hybrid approach using one shared function for controls that behave identically and dedicated functions for complex controls like the ListView, TreeView, etc.

Messages like WM_MOUSEMOVE or WM_NCHITTEST fire constantly and it doesn't make sense regarding performance to have huge different Case statements for every pixel the mouse moves, Also drawing complex GDI+ functions in WM_PAINT or WM_ERASEBKGND may reduce the overall performance.

 

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Running the code below results in an error in GUIDarkTheme.au3.

Func _GUIDarkTheme_GUICtrlAllSetDarkTheme($g_hGuiWnd, $bEnableDarkTheme = True, $bPreferNewTheme = False)

 

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>
#include "GuiCtrls_HiDpi.au3"
#include "GUIDarkTheme.au3"


$hGui = GUICreate("", 300, 200)

#Region MENU
Local $idMenu1 = GUICtrlCreateMenu("Menu &One")
Local $idMenu2 = GUICtrlCreateMenu("Menu &Two")
#EndRegion MENU

_GUIDarkTheme_ApplyDark($hGui)
GUISetState()

While 1
    Sleep(10)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

 

An @error check fixes the error.

 

Func _GUIDarkTheme_GUICtrlAllSetDarkTheme($g_hGuiWnd, $bEnableDarkTheme = True, $bPreferNewTheme = False)
    Local $aCtrls = __WinAPI_EnumChildWindows($g_hGuiWnd, False)
    If @error = 0 Then
        For $i = 1 To $aCtrls[0][0]
            _GUIDarkTheme_GUICtrlSetDarkTheme($aCtrls[$i][0], $bEnableDarkTheme, $bPreferNewTheme)
        Next
    EndIf
    Local $aCtrlsEx = __WinAPI_EnumProcessWindows(0, False) ; allows getting handles for tooltips_class32, ComboLBox, etc.
    For $i = 1 To $aCtrlsEx[0][0]
        _GUIDarkTheme_GUICtrlSetDarkTheme($aCtrlsEx[$i][0], $bEnableDarkTheme, $bPreferNewTheme)
    Next
    Return $aCtrls
EndFunc   ;==>_GUIDarkTheme_GUICtrlAllSetDarkTheme

 

Edited by bladem2003
Posted
38 minutes ago, bladem2003 said:

An @error check fixes the error.

Nice work and thank you for the fix. :)

I knew that there was a crash when there were no controls added but I had no idea exactly where the crash was coming from. So I appreciate that you figured it out.

By the way, should there be an @error check on the second loop as well?

Posted
17 minutes ago, WildByDesign said:

...should there be an @error check..

..just passing by.
@error checking should be done everywhere.
We add it only after we experience and error but somebody else may crash because of "that didn't happen to me when..." and I call BS !
So yes, do add @error checking everywhere, or at least where the failure would crash the script.

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

Posted (edited)

That can't be wrong, so do it. 😉

PS: Thanks for your excellent work!

It's incredible that you have so much time and manage to accomplish all of this.

 

I'd like to mention that almost all of my posts are translated by Google Translate. Sorry.

 

Edited by bladem2003
Posted (edited)

I seem to have a bit of a roadblock in the overhauling/reorganizing of the window procedures used for subclassing. I am trying to organize things better but also make it so that it can support multiple of the same control types (eg. 2 or 3 ListViews, etc.). If this UDF is to be used on any AutoIt GUI, it would need to support multiple of any control type.

EDIT: I have resolved this issue now.

Edited by WildByDesign
Posted

Big lovely update with a pretty big changelog. I spent about a week perfecting all of the details, fixing minor bugs and so on. I feel quite good about this update. :)

Updated files will always be in the first post of this thread.

GUIDarkTheme 1.3.0:

  • Added dark mode MsgBox with new _GUIDarkTheme_MsgBox() function - (thanks to MattyD)
    • Default dark MsgBox colors are nice, but you can use _MsgBoxDarkSetOptions() to customize
    • Dark MsgBox is not completely automated:
    • You would need to manually replace your MsgBox() with _GUIDarkTheme_MsgBox()
    • Parameters are the same between the two functions
    • _GUIDarkTheme_MsgBox() can automatically switch between dark and light modes
  • Added SampleControls-MaterialDark.au3 (to not take anything away from SampleControls-ModernDark.au3)
  • Added Sizebox/sizegrip overpainting on Edit, TreeView and ListView controls (thanks to UEZ)
  • Added control border painting to easily show which control has focus and keep theme consistent (thanks to UEZ)
  • Fixed crash when no controls are on GUI (thanks to bladem2003)
  • Ran all .au3 files in 7z archive through Tidy
Posted (edited)
9 minutes ago, argumentum said:

... I believe that after v0.8.6 the code broke the bottom right corner resize thing. If you minimize the examples and restore it, you'll see that you can now resize the GUI 😕 

Oh that is wacky. 😆

I remember you mentioning that before but for some reason I never ended up doing a simple minimize/restore at all during testing. I just reproduced it now. This definitely needs to be fixed.

I probably should add a dark mode MsgBox example to the button on the examples.

Edited by WildByDesign
Posted

GUIDarkTheme 1.4.0:

  • Added single function _GUIDarkTheme_SwitchTheme() to switch between Dark and Light mode
  • Expanded _GUIDarkTheme_MsgBox() functionality to allow standard dark mode buttons or materials
    • If a material is applied to GUI, buttons will automatically switch to allow material as well
  • Condensed all 3 SampleControls scripts into one: SampleControls-Demo.au3
    • Menubar has been changed to File, Options, and Help
    • Options - Toggle Theme has been added to showcase instant switch between Dark and Light mode
    • Help - About menu gives UDF version but also is an example of dark MsgBox
  • Condensed both Statusbar scripts into one: Statusbar-Demo.au3
    • Statusbar-Demo has an extra button "Toggle Dark Themes" that only shows on 24H2/25H2 OS (build 26100.6899 and higher)
    • "Toggle Dark Themes" switches back and forth between DarkMode_Explorer and DarkMode_DarkTheme (newer dark theme)

NOTE: There is a minor issue with switching back and forth between Dark and Light mode regarding Static controls. There isn't really a "one size fits all" approach to getting the background and foreground colours right for every situation.

Please keep in mind that you can always use GUICtrlSetBkColor and GUICtrlSetColor after applying these themes to override colours that are specific to your needs.

I am thinking about exploring _WinAPI_GetTextColor and _WinAPI_InvertColor for Static controls but I haven't tested it yet.

Posted

I am planning to add easy applying of Windows 11 materials to the GUI in the Demo script. I already have the function for it in the UDF and it was showcased in the SampleControls-MaterialDark script in previous release.

So I just have to add the material options to the menu and likely do options for window corners (eg. Rounded, square, etc).

I have a lot of stuff planned to make this an overall comprehensive modern theming UDF. 

Posted

GUIDarkTheme 1.5.0:

  • UpDown (spin) controls are now subclassed as well (courtesy of @Nine)
    • Previously, UpDown controls could not obtain dark mode on Windows 10
  • Reorganized much of the subclassing registration under __GUIDarkTheme_AddToSubclass() function
    • This is mostly to cover subclass registration for the procedures that are created using _WinAPI_SetWindowSubclass()
    • All control handles, procedure pointers and subclass ID's are stored in a single array for easy cleanup
    • At the moment, this covers __GUIDarkTheme_UpDownProc() and __GUIDarkTheme_SubclassProc() - general GUI procedure
    • I would like to switch more of the subclassing procedures over to this method in future releases

Updated script files are on the first post as always. :)

@bladem2003 I remember from the previous UDF thread that you use Windows 10 and wanted dark mode UpDown controls. Please give this release a try and let me know if it works well or not. Thank you.

Posted

I was looking at the code and saw  Global $hGdi32Dll = DllOpen("gdi32.dll")  then am like hmm, the GDI UDF uses  Global $__g_hGDIPDll = 0
You could use $__DM_g_hDllGdi32. That way it complies with everything as far as been "internal use only", and of the DM UDF "signature", and type, and easily searchable because all the internal globals start with the same unique "$__DM_g_". The "hDll" shows that is a DLL, so $__DM_g_hDllName also makes it easier to see.
Is a simple global replace in any coding editor.

Also adding $__DM_g_Version = "1.2.3.4" gives a way to know the version via code in a helper function MyUdfVersion()

You're giving us a very good looking UDF. Works quite nice. Thanks :)

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

Posted
1 hour ago, argumentum said:

You're giving us a very good looking UDF. Works quite nice. Thanks :)

You're welcome. And thank you. That means a lot to me. :)

1 hour ago, argumentum said:

You could use $__DM_g_hDllGdi32. That way it complies with everything as far as been "internal use only", and of the DM UDF "signature", and type, and easily searchable because all the internal globals start with the same unique "$__DM_g_". The "hDll" shows that is a DLL, so $__DM_g_hDllName also makes it easier to see.

Just to clarify, you want me to change the following:

Global $hGdi32Dll = DllOpen("gdi32.dll")
Global $hUser32Dll = DllOpen("user32.dll")
Global $hKernel32Dll = DllOpen("kernel32.dll")
Global $hShlwapiDll = DllOpen("shlwapi.dll")
Global $hUxthemeDll = DllOpen("uxtheme.dll")
Global $hComctl32Dll = DllOpen("comctl32.dll")

To the following:

Global $__DM_g_hDllGdi32 = DllOpen("gdi32.dll")
Global $__DM_g_hDllUser32 = DllOpen("user32.dll")
Global $__DM_g_hDllKernel32 = DllOpen("kernel32.dll")
Global $__DM_g_hDllShlwapi = DllOpen("shlwapi.dll")
Global $__DM_g_hDllUxtheme = DllOpen("uxtheme.dll")
Global $__DM_g_hDllComctl32 = DllOpen("comctl32.dll")

I am open to changing it. That is no problem. If that is what you suggest, I can make that change.

Posted

GUIDarkTheme 1.6.0:

  • Theme switching is faster and smoother now with the use of _WinAPI_LockWindowUpdate()
  • Global variable stored now with GUIDarkTheme UDF version: $__DM_g_Version
  • Global variables for DLL handles now precede with: $__DM_g_hDll (eg. $__DM_g_hDllGdi32)
  • Global Style constants now precede with: $__DM_g_Style_ (eg. $__DM_g_Style_Gui)
  • Cleaned up some of the subclassing to ensure clean removal, especially when switching themes
  • Removed some dead code

 

18 hours ago, argumentum said:

And the version thing too

This ended up being beneficial because now I just add this variable to the MsgBox in the SampleControls-Demo GUI. Previously, I had to remember to update that version number manually each release. :)

Posted

GUIDarkTheme 1.6.1:

  • Added more tabs to the tab control for testing the overflow and UpDown (spin) control
    • Ensured that tab overflow (UpDown) created after init will still get subclassed
    • Done via $WM_PARENTNOTIFY in the Tab Proc - courtesy of UEZ
  • Added _GUIDarkTheme_Version() to check UDF version - courtesy of argumentum
  • Some minor subclass reorganization

@UEZ If you have some time, could you please help test something with this release?

There is a problem in the tab control when showing the UpDown (spin) control. It also affects your SampleControls.au3 in Dark Mode when you add more tabs to it since GUIDarkTheme UDF uses your TabProc subclass.

Repro: If you click back and forth between tabs a few times (or even just click on the same tab a few times), the UpDown control within the tab control disappears and reappears randomly. My guess is that it may be getting overdrawn by the tab control.

Posted

I added the exlusion for the up/down control in Case $WM_PAINT (_WinProc() function).

; also exclude the system Up/Down of the TabControl itself
            Local $hTabUpDown = _WinAPI_FindWindowEx($hWnd, "msctls_updown32")
            If $hTabUpDown And _WinAPI_IsWindowVisible($hTabUpDown) Then
                $tCR = _WinAPI_GetWindowRect($hTabUpDown)

                If Not ($tCR.right < $tPR.left Or $tCR.left > $tPR.right Or _
                        $tCR.bottom < $tPR.top Or $tCR.top > $tPR.bottom) Then

                    $left = Max($tCR.left, $tPR.left) - $tPR.left
                    $top = Max($tCR.top, $tPR.top) - $tPR.top
                    $right = Min($tCR.right, $tPR.right) - $tPR.left
                    $bottom = Min($tCR.bottom, $tPR.bottom) - $tPR.top

                    DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hMemDC, "int", $left, "int", $top, "int", $right, "int", $bottom)
                    DllCall("gdi32.dll", "int", "ExcludeClipRect", "handle", $hDC, "int", $left, "int", $top, "int", $right, "int", $bottom)
                EndIf
            EndIf

This works for me. up/down control will be displayed when more tabs are added than it can be displayed.

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