Set Gadget Background and Text Colors automatically based on the window's color or parent container's color.
PureBasic, Windows only
Supported gadget: Calendar, CheckBox, ComboBox, Container, Date, Editor, ExplorerList, ExplorerTree, Frame, HyperLink, ListIcon, ListView, Option, Panel, ProgressBar, ScrollArea, Spin, String, Text, TrackBar, Tree
Notes: For the ComboBoxGadget, #CBS_HASSTRINGS and #CBS_OWNERDRAWFIXED must be added at Combobox creation time
ex: ComboBoxGadget(#Gasdget,X,Y,W,H,#CBS_HASSTRINGS|#CBS_OWNERDRAWFIXED)
To receive its events in the Window Callback and be drawn with the chosen colors.
It does not work for ComboBox with #PB_ComboBox_Image constant, in this case do Not add #CBS_HASSTRINGS|#CBS_OWNERDRAWFIXED
For ButtonGadget, you can use JellyButtons.pbi to get nice colored buttons. It is included in IceDesign GUI Designer
Add: XIncludeFile "ObjectColor.pbi"
- SetObjectColor([#Window, #Gadget, BackColor, TextColor])
#Window:
-- #PB_All = All Window (Default).
-- The Window number to use.
#Gadget:
-- #PB_All = All Supported Gadgets (Default).
-- The Gadget number to use.
BackColor:
-- #PB_Auto = Same as parent container's color (Default).
-- The new backgound color. RGB() can be used to get a valid color value.
-- #PB_Default = to go back to the default system backgound color.
TextColor:
-- #PB_Auto = White or Black depending on whether the background color is dark or light (Default).
-- The new text color. RGB() can be used to get a valid color value.
-- #PB_Default = to go back to the default system text color.
For all gadgets with automatic background color and text color use: SetObjectColor()
- SetObjectColorType([Type.s])
Type:
-- Without Type for all supported Gadget. It is done automatically if SetObjectColorType() is not used.
-- "NoEdit" for all supported Gadget except String and Editor.
-- "ColorStatic" for CheckBox, Frame, Option and TrackBar only (WM_CTLCOLORSTATIC).
-- 1 or multiple #PB_GadgetType_xxxxx separated by comma. The parameter is a String, so between quotes. Ex: SetObjectColorType("#PB_GadgetType_CheckBox, #PB_GadgetType_Option").
- SetDarkTheme(Gadget) : - Enable DarkMode_Explorer Theme (> Windows 10)
- SetExplorerTheme(Gadget) : - Enable Explorer Theme (> Vista) for the same Gadgets
Theme is applied for ComboBox, Editor, ExplorerList, ExplorerTree, ListIcon, ListView, ScrollArea, ScrollBar and Tree Gadget - To Debug with the hierarchical list of gadgets with their colors, change the constant #DebugON = #True