Saturday, September 27, 2008

Using the ToolBar Control in VB6

In earlier 16-bit releases of Visual Basic, it was difficult to implement a toolbar for your users. You had to place a PictureBox control on a form and then add CommandButton controls to the PictureBox to simulate the toolbar. Starting with the 32-bit version of Visual Basic 4.0 and continuing with all subsequent versions of VB, you have the ToolBar ActiveX control that you can add to your forms to easily implement toolbar functionality for your users.

A toolbar is becoming a standard feature of Windows applications. Toolbars provide functionality to a user through an easily accessible, graphical interface. For common functions the user does not need to navigate through a menu or remember shortcut keys to use an application. Applications can expose their most common features through buttons on a toolbar.
Product Spotlight
Why are you still hand-coding?
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Visually stunning, easy to customize and ready to deploy. Download Now!
Setting Custom Properties

The ToolBar control is available through the Windows Common Controls, along with the TreeView, ListView, and ImageList . After you have drawn a toolbar on a form, you will usually start by setting properties through the Property Pages dialog box for the control.

On the first tab of the Property Pages dialog box, as shown in Figure 4.9, one of the options you will set most often is the ImageList . Like the TreeView and the ListView controls, the toolbar gets images from an ImageList control. If you are building a toolbar that will have graphics on its buttons, you will first need to add an ImageList control to the form and then bind that ImageList to the toolbar through the Property Pages dialog box.

General tab of the Custom Properties of a toolbar.
FIGURE 4.9 General tab of the Custom Properties of a toolbar.

Several other properties are unique to the toolbar and can be set on the General tab. The ButtonHeight and ButtonWidth properties determine the size of buttons that appear on the toolbar. All buttons will have the same height and width. The number of buttons that can appear on a toolbar is determined by the size of the buttons and the width of the window. If you want the toolbar and buttons to wrap when the window is resized, you can set the Wrappable property of the toolbar to True.

No comments: