How do I paint tool bars and main menus different colors?

I have been trying all day long to draw the toolbar background red but to no avail. The OnPaint event is not ever called when I inherit from ToolBar.

But when I inherit from UserControl or Button the OnPaint event is fired, but that is pretty useless to me because it is not anything like a toolbar.

And, the ToolBar in VS does not have a DrawMode option for it. So I cannot Owner Draw. I don't think so anyway. It seems like I would have to create my own toolbar control from scratch. What do you think?
 
The answer is probably. The Toolbar in the .NET framework is not a complete control in itself, it only wraps the win32 common controls toolbar. This won't always be the case, but that's how it is at the moment. That means that you almost certainly won't be able to owner draw it in any elegant way.

The only way you'd be able to owner draw it is to override its WndProc method and listen for the WM_PAINT message. You might be able to do some more stuff specific to the toolbar by sending it messages and creating win32 brush objects for it when it asks for them.

Creating your own toolbar from scratch will probably be about as much work, and give you far more control (obviously). I've written my own, which works well. It does more than the win32 one does. You might want to read the article I wrote on writing collection-driven controls like this, it goes in to the best way to design them. The sample project that comes with it could be converted to a functioning toolbar quite easily.

Read it here
 
Divil, I found a small mistake in your page:

but in this case we want to hide then. (them)

That is under the Adding the designer section.

Here is another one:

Adding Buttons

The first thing we want the user to be able to do is to buttons.
 
Back
Top