UEZ Posted April 2 Posted April 2 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. WildByDesign 1 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
bladem2003 Posted April 2 Posted April 2 (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 April 2 by bladem2003 WildByDesign 1
WildByDesign Posted April 2 Author Posted April 2 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?
argumentum Posted April 2 Posted April 2 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. WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
bladem2003 Posted April 2 Posted April 2 (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 April 2 by bladem2003 WildByDesign 1
WildByDesign Posted April 3 Author Posted April 3 (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 April 4 by WildByDesign
WildByDesign Posted April 6 Author Posted April 6 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 argumentum 1
argumentum Posted April 6 Posted April 6 ... 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 😕 WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted April 6 Author Posted April 6 (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 April 6 by WildByDesign argumentum 1
WildByDesign Posted April 6 Author Posted April 6 GUIDarkTheme 1.3.1: Added dark mode MsgBox example to the button SampleControls-MaterialDark has material applied to MsgBox Fixed bug where sizebox was showing up after minimize/restore of GUI that was not intended to be resizable Thanks to @argumentum for reporting and @ioa747 for helping with the fix argumentum and ioa747 2
WildByDesign Posted April 9 Author Posted April 9 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. bladem2003, argumentum and ioa747 2 1
WildByDesign Posted April 9 Author Posted April 9 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. bladem2003 and argumentum 2
WildByDesign Posted Monday at 12:17 PM Author Posted Monday at 12:17 PM 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. argumentum 1
argumentum Posted Monday at 03:59 PM Posted Monday at 03:59 PM 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 WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted Monday at 05:28 PM Author Posted Monday at 05:28 PM 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.
argumentum Posted Monday at 05:46 PM Posted Monday at 05:46 PM 16 minutes ago, WildByDesign said: I am open to changing it. That is no problem. If that is what you suggest, I can make that change. Yes please do. And the version thing too ( for debugging ) WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Monday at 05:57 PM Posted Monday at 05:57 PM ...and the other file too 🤔 These declarations ( $_g__Style_Gui ) would benefit from standardizing the globals to avoid collisions with other sources/scrips and unlikely to be used by a user. WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted Tuesday at 12:28 PM Author Posted Tuesday at 12:28 PM 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. argumentum 1
WildByDesign Posted yesterday at 11:11 AM Author Posted yesterday at 11:11 AM 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. argumentum 1
UEZ Posted 4 hours ago Posted 4 hours ago 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. WildByDesign 1 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now