Change Toolbar Background Color

Just starting out? Need help? Post your questions and find answers here.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Change Toolbar Background Color

Post by milan1612 »

Does anybody know how to change the background color of a toolbar?
Thanks, milan1612
Windows 7 & PureBasic 4.4
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

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?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Ah :idea: , thanks anyway :)
Windows 7 & PureBasic 4.4
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post 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 8)
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It's impossible to do with the XP-style toolbar buttons because they are bitmaps and not coloured on the fly.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Impossible <-> Purebasic
That doesn't fit at all! :lol:
Windows 7 & PureBasic 4.4
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Well, if trond's going to say impossible, I might take a look... :D
BERESHEIT
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

You can of course draw your own toolbar buttons, but you can't change the colour of the existing ones.
Post Reply