vbAccelerator CommandBar Control
The vbAccelerator CommandBar control is a full toolbar/menu control which currently offers configurable styles, colours and a full-object model for configuring the buttons and menus. The control can draw in Office 2003, Office XP, MS Money and System styles, supports icons with alpha-channels and runs on any Windows system. The control is currently a pre-release version, and although it can be used now, some important features have not yet been implemented, particularly MDI support, docking container and toolbar borders.
The Command Bar control contains two main collections: the CommandBars collection and the Buttons collection. Once buttons have been added to the Buttons collection, they can be assigned to any CommandBar, and the same button can appear in more than one command bar. Adding drop-down menus to any button is achieved by assigning a CommandBar to the button.
In order to allow multiple controls access to the same buttons and command bars, these collections are global. It is important to note that this means the collections are global to your project, not just to a particular form that the command bar is sited on. This will be most noticable when writing a multiple form project (article describing this coming soon).
The object model for the control is shown diagrammatically below:
Properties, Methods and Events
This section describes the main properties, methods and events of the objects in the CommandBar control. The collection objects are not described as they contain the standard Add, Remove, Count and default Item properties (although note that For..Each enumeration is not supported).
The behaviour of a button in a control is primarily configured by the button's Style, which is set when the button is added. There are seven styles of buttons provided in the control:
The other properties in the control can be modified at any time:
A CommandBar has three properties:
3. The vbalCommandBar Controls
In addition to providing access to the global button and bar collections, the command bar control is also responsible for displaying toolbars and menus on the screen. As VB lacks a simple way to instantiate a new control and have it added to its own container from within a control, command bar controls make requests to their containers for new instances. Since controls which display menus also raise click events, this means it is always best to use command bar controls in a control array.
Once the instance(s) of the CommandBar have been created, you can start setting the properties and styles of the command bars to display. There are four style settings which can be used in the control, and in three of the styles all the colours that are used can be customised. Note that styles and colours are global and setting them in one command bar control instance will affect all others. The following images show the different styles of the CommandBar:
Styles are set using the Style property, and the colours used in the style can be customised using the CustomColor, StyleColor and UseStyleColor properties.
Each CommandBar has two Image Lists associated with it (note that these are not currently global properties but probably will be so in the next release), the ToolBarImageList and the MenuImageList. These may be set to point to the same image list if desired. The properties can be set to a Microsoft Windows Common Controls ImageList or any ImageList based on ComCtl32.DLL that exposes a hImageList property.
If the command bar control is to be used as the main menu in the application, set the MainMenu property to True. This configures the control so it will wrap onto a new line when the form is resized, and it also changes the background to the toolbar to the correct style for the menu.
Any toolbar can have a background image, and this image can be Image Processed using the built in image modification properties. The background image can be set using the BackgroundImage property and the hue, luminance or saturation can be modified using AdjustBackgroundImage. There is also a method AdjustImage which can apply the same effects to any picture.
To set the control to show a particular bar, set the Toolbar property. This takes a cCommandBar object, or Nothing to stop the control displaying a bar. The orientation of the toolbar is configured using the Orientation property, and the control can also be Aligned to any side of a form.
To Do List
The following features are due to be implemented for the full release, due at the beginning of March:
In the meantime, send any bug reports and I will do my best to fix them.