bladem2003 Posted 3 hours ago Posted 3 hours ago (edited) Inspired by @WildByDesign https://www.autoitscript.com/forum/topic/213613-guidarktheme-udf/, I created a dark theme UDF for AutoIt, along with a GUI Creator for designing interfaces and exporting them as AutoIt code. The UDF supports a wide range of standard controls, with custom owner-drawn progress bars and sliders. It also provides customizable colors for backgrounds, text, selections, tabs, progress bars, and sliders, plus disabled states, hover effects, DPI scaling, and adjustable slider thumbs. It definitely doesn't measure up to the UDF by @WildByDesign. Dark themed controls — Consistent dark styling for common AutoIt controls, including buttons, labels, edits, combo boxes, list boxes, list views, tree views, tabs, and group boxes. Custom drawn controls — Progress bars and sliders are owner-drawn, allowing their colors, text, thumb appearance, and other visual details to be customized. GUI Creator — A visual editor for placing and sizing controls, adjusting supported properties, previewing the interface, and exporting AutoIt source code. Control notes ListBox: For themed selection colors, create the list with $LBS_OWNERDRAWFIXED and $LBS_HASSTRINGS. Pass $WS_VSCROLL in the style argument of GUICtrlCreateList. Slider: Set the range with GUICtrlSetLimit($idSlider, maximum, minimum). A larger range, such as 0–1000, gives finer value steps when clicking along the track. Choose a range that matches the values your application needs. Progress bar: The UDF supports customized progress colors and text, percentage display, and corner styling, with global defaults and per-control options. Labels and static controls: Use _DarkTheme_SetControlBackgroundColor() for a custom background. Custom-painted labels do not use GUICtrlSetBkColor() for that background. Tabs, ListViews, and TreeViews: Create these controls normally, then apply the theme after all controls have been created. GUIDarkTheme.7z Edited 3 hours ago by bladem2003 WildByDesign and ioa747 2
WildByDesign Posted 27 minutes ago Posted 27 minutes ago (edited) Excellent job! I haven't gotten around to checking out exactly how everything works in the UDF, but I really like your coding style from the parts that I did check out so far. Also the dark themed GUI Creator is definitely something that we need. The Creator looks and feels great. I have a quick fix for you for the rounded buttons which appear more squared at the moment. You just have to return a brush for $WM_CTLCOLORBTN that is equal to your GUI background brush. Switch $iMsg Case $WM_CTLCOLOREDIT, $WM_CTLCOLORLISTBOX, $WM_CTLCOLORSCROLLBAR, $WM_CTLCOLORBTN If $bEnabled Then $iTextColor = __DarkTheme_GetControlTextColor($hCtrl, $g_DarkThemeTextColor) $iBackgroundColor = __DarkTheme_GetControlBackgroundColor($hCtrl, $g_DarkThemeControlColor) _WinAPI_SetTextColor($hDC, _WinAPI_SwitchColor($iTextColor)) _WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor($iBackgroundColor)) If $iMsg = $WM_CTLCOLORLISTBOX Then _WinAPI_SetBkMode($hDC, 2) Else _WinAPI_SetBkMode($hDC, $TRANSPARENT) EndIf ; added this below If $iMsg = $WM_CTLCOLORBTN Then Local Static $hBtnBkBrush = _WinAPI_CreateSolidBrush(0x202020) Return $hBtnBkBrush EndIf ; Return __DarkTheme_GetControlBackgroundBrush($hCtrl, $g_DarkThemeBrush) EndIf This is working, but it is a poor implementation on my part because I didn't really dig into where your colors are coming from yet. But change that to your coding style and that is how the rounded buttons go. The next thing is something that I only discovered just recently, but not related to the buttons. ; Add dark background brush directly to 'AutoIt v3 GUI' window class Local $hDarkBrush = _WinAPI_CreateSolidBrush(0x202020) ; Do this right after GUICreate _WinAPI_SetClassLongEx($hGui, $GCL_HBRBACKGROUND, $hDarkBrush) It sets a default hbrBackground brush for the GUI. The cool part about it is that it becomes the default brush for WM_ERASEBKGND which would typically be a white color returned by DefWindowProc for most controls by default. So by changing this, it can prevent any flicker especially when resizing or DPI changes and things like that. Edited 26 minutes ago by WildByDesign
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