tags:

views:

39

answers:

4

Is there a way to set the background color. I thought of making a dummy window and then using TBSTATE_TRANSPARENT, but I thought there might be a cleaner solution?

Thanks

None of these solutions work for a toolbar using visual styles

A: 

Check out TB_SETCOLORSCHEME.

Jim Lamb
When visual styles are enabled, this message has no effect.
Milo
Also this sets button color not back color
Milo
A: 

What you need to do is redraw the toolbar entirely by handling WM_PAINT

Read this article: http://www.codeguru.com/cpp/controls/toolbar/flattoolbar/article.php/c2535/

Yonathan Klijnsma
A: 

Could you subclass the toolbar window and either handle the WM_ERASEBKGND message or handle the WM_CTLCOLORDLG message and return your desired background brush?

You might also be able to do something with WM_CTLCOLORBTN - this doesn't require that you subclass the window since it's handed to the parent window.

Larry Osterman
A: 

You can call SetClassLong() with GCL_HBRBACKGROUND and pass a brush you created with CreateSolidBrush().
You can also pass in a pattern brush if you want the background to be an image.

Alex K.