Change colours of window
Posted: Sat May 25, 2024 6:45 am
How do you change all the colours of a window? Make a dark mode app? Change the toolbar colour? I can't find any options.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
UsePNGImageDecoder()
thBrush = CreateSolidBrush_($0)
Enumeration DWMWINDOWATTRIBUTE
#DWMWA_USE_IMMERSIVE_DARK_MODE = 20
EndEnumeration
PrototypeC.i DwmSetWindowAttribute(hwnd.i, dwAttribute.l, *pvAttribute, cbAttribute.l)
Define.DwmSetWindowAttribute DwmSetWindowAttribute
Define.i UseDarkMode
OpenWindow(0, 50, 50, 600, 400, "DarkMode Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_SizeGadget)
UseDarkMode = 1
If OpenLibrary(0, "dwmapi")
DwmSetWindowAttribute = GetFunction(0, "DwmSetWindowAttribute")
DwmSetWindowAttribute(WindowID(0), #DWMWA_USE_IMMERSIVE_DARK_MODE, @UseDarkMode, SizeOf(UseDarkMode))
CloseLibrary(0)
EndIf
SetWindowColor(0,0)
ContainerGadget(1,0, -2,600,24,#PB_Container_BorderLess)
CloseGadgetList()
TB = CreateToolBar(0, GadgetID(1))
LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\world.png")
ToolBarImageButton(0,ImageID(0))
SetClassLongPtr_(GadgetID(1), #GCL_HBRBACKGROUND, thBrush)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Code: Select all
thBrush = CreateSolidBrush_($0) ;Change $0 to what you want
Code: Select all
UsePNGImageDecoder()
thBrush = CreateSolidBrush_($00303030)
Enumeration DWMWINDOWATTRIBUTE
#DWMWA_USE_IMMERSIVE_DARK_MODE = 20
EndEnumeration
PrototypeC.i DwmSetWindowAttribute(hwnd.i, dwAttribute.l, *pvAttribute, cbAttribute.l)
Define.DwmSetWindowAttribute DwmSetWindowAttribute
Define.i UseDarkMode
OpenWindow(0, 50, 50, 600, 400, "DarkMode Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_SizeGadget)
UseDarkMode = 1
If OpenLibrary(0, "dwmapi")
DwmSetWindowAttribute = GetFunction(0, "DwmSetWindowAttribute")
DwmSetWindowAttribute(WindowID(0), #DWMWA_USE_IMMERSIVE_DARK_MODE, @UseDarkMode, SizeOf(UseDarkMode))
CloseLibrary(0)
EndIf
CreateMenu(0, WindowID(0))
MenuTitle("File")
MenuItem(MenuID(0), "Open...")
MenuItem(MenuID(0), "Save As...")
MenuItem(MenuID(0), "Save")
MenuItem(MenuID(0), "Quit")
SetWindowColor(0, $202020)
ContainerGadget(1, 0, -2, 600, 24, #PB_Container_BorderLess)
CloseGadgetList()
TB = CreateToolBar(0, GadgetID(1))
LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\world.png")
ToolBarImageButton(0,ImageID(0))
SetClassLongPtr_(GadgetID(1), #GCL_HBRBACKGROUND, thBrush)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend