Page 1 of 1
Change Toolbar Background Color
Posted: Wed May 02, 2007 2:36 pm
by milan1612
Does anybody know how to change the background color of a toolbar?
Thanks, milan1612
Posted: Wed May 02, 2007 5:05 pm
by Fluid Byte
Toolbars have a transparent background, just change the windows color where it's attached on.
Posted: Wed May 02, 2007 7:53 pm
by milan1612
Ah

, thanks anyway

Posted: Wed May 02, 2007 7:59 pm
by Fluid Byte
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.
Posted: Wed May 02, 2007 9:01 pm
by Fluid Byte
I got some code working but it doesn't support XP Skins and only works with FLAT TB style.
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 : Wend
Here's another one with the technique I described first (works with XP):
Code: 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 : Wend
Posted: Wed May 02, 2007 9:25 pm
by milan1612
Hi,
I need XP Styles in my app, so ...
I am using SmartWindowRefresh and changing the color of the window
makes it flickering again :roll:
Well, OK, I can live with the Standard Toolbar, thanks anyway

Posted: Wed May 02, 2007 9:36 pm
by Trond
It's impossible to do with the XP-style toolbar buttons because they are bitmaps and not coloured on the fly.
Posted: Wed May 02, 2007 9:56 pm
by milan1612
Impossible <-> Purebasic
That doesn't fit at all!

Posted: Wed May 02, 2007 10:01 pm
by netmaestro
Well, if trond's going to say impossible, I might take a look...

Posted: Thu May 03, 2007 11:35 am
by Trond
You can of course draw your own toolbar buttons, but you can't change the colour of the existing ones.