Change Toolbar Background Color
Change Toolbar Background Color
Does anybody know how to change the background color of a toolbar?
Thanks, milan1612
Thanks, milan1612
Windows 7 & PureBasic 4.4
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Toolbars have a transparent background, just change the windows color where it's attached on.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
FYI, I just tested serval methods to accomplish this but I had no success. Even though I removed the transparency (#TBSTYLE_TRANSPARENT), hooked on a callback and processed #WM_ERASEBKGND I couldn't get it to work. Also messing with various style constants didn't bring me far. This is a really nasty bugger. Lemme see if I can trick it somehow.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
I got some code working but it doesn't support XP Skins and only works with FLAT TB style.
Here's another one with the technique I described first (works with XP):
Code: Select all
OpenWindow(0,0,0,300,200,"untitled",#WS_OVERLAPPEDWINDOW | 1)
hwndTB = CreateToolBar(0,WindowID(0))
For i=0 To 10 : ToolBarStandardButton(i,i) : Next
dwStyle = #WS_CHILD | #WS_VISIBLE | #CCS_TOP | #CCS_NODIVIDER | #TBSTYLE_FLAT
hBrushBack = CreateSolidBrush_(#Red)
SetWindowLong_(hwndTB,#GWL_STYLE,dwStyle)
SetClassLong_(hwndTB,#GCL_HBRBACKGROUND,hBrushBack)
While WaitWindowEvent() ! 16 : WendCode: Select all
OpenWindow(0,0,0,300,200,"void",#WS_OVERLAPPEDWINDOW | 1)
OpenWindow(1,0,0,WindowWidth(0),25,"",#WS_CHILD,WindowID(0))
hwndTB = CreateToolBar(0,WindowID(1))
For i=0 To 10 : ToolBarStandardButton(i,i) : Next
SetWindowColor(0,#Blue)
SetWindowColor(1,#Red)
While WaitWindowEvent() ! 16 : WendWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
