Change colours of window
Change colours of window
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.
Re: Change colours of window
For Windows 10,11
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
Egypt my love
Re: Change colours of window
Looks good except can you change the toolbar colour?
Also can it be done on Linux and Mac?
Also can it be done on Linux and Mac?
Re: Change colours of window
For ToolBar Color
For Linux & Mac
Ask mk-soft or Shardik
Code: Select all
thBrush = CreateSolidBrush_($0) ;Change $0 to what you want
Ask mk-soft or Shardik
Egypt my love
Re: Change colours of window
Can you do the menus?
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
Re: Change colours of window
For some reason PureBasic also cannot set the background colour of buttons
Re: Change colours of window
Maybe you could try this:
https://www.purebasic.fr/english/viewto ... =dark+mode
https://www.purebasic.fr/english/viewto ... =dark+mode
Re: Change colours of window
RASHAD - looks like Linux and Mac do it automatically
Caronte3D - thank you that might do it
Caronte3D - thank you that might do it


