Check out the toolbar and the status bar in Edwina. I won’t get into the code but will simply say that I had to implement these features the same way everyone else does—with blood, sweat, and profanity. Figure 11-15 shows a map that will perhaps lessen your frustration.
Figure 11-15. A Toolbar map.
To use a Toolbar control efficiently, you must understand ImageLists and collections inside and out. Plan the buttons in detail, and get your ImageList right the first time because every time you change a button image, you’re in trouble. You must unhook the ImageList from the Toolbar control to modify, insert, or delete an image, even though unhooking means that all your button indexes are destroyed and that you must reinitialize them one by one. You might even consider attaching the ImageList with code at run time rather than trying to manage it at design time.
Most of the work involved in creating a toolbar is directed toward managing the Buttons collection and coordinating it with the ListImages collection of the ListImage. The Panels collection of the StatusBar control is a little easier because you don’t have to worry about ImageLists.
I don’t mind that toolbars are based on the ImageList control, but I shouldn’t have to worry about it. When I set up toolbar buttons, I want to just click a button that brings up the Picture dialog box and lets me install the button image. If the dialog box adds the image to an ImageList behind the scenes and ties the image index to a button index, that’s OK with me. But as a user, I don’t care about this implementation detail. I just want to put images on buttons. Any add-in vendor who gives me a tool that hides the connection between toolbars and ImageLists will get my business. It should be a simple matter now that you can create delegated controls. In fact, there isn’t much wrong with a Toolbar control that couldn’t be fixed by giving it a more sophisticated and user-friendly property page. It’s kind of a disgrace that toolbars are still treated as some extra feature that you can add if you have the patience. But toolbars aren’t an extra feature—they’re the standard. Every program should have one. They should have a toolbar editor that is as integrated and easy to use as the Menu editor. But enough of this ranting. At least now I can put a Flame button on my toolbars.