|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
The code for this example is located in the progressbar folder on this books accompanying CD-ROM. Adding A Coolbar To A FormCoolbars were first introduced in the Microsoft Internet Explorer, and they are toolbars that present controls in bands. The user can adjust these bands by dragging a gripper, which appears at left in a band. In this way, users can configure the coolbar by sliding the bands around as they want. To add a coolbar control to a form, follow these steps:
Now that youve added a coolbar to your form, maybe youll need to align it in that form? See the next topic for the details. Aligning Coolbars In A FormNow that youve added a coolbar to your form, how do you align it to the top, bottom, or wherever you want to place it? You use the Align property, setting it to one of these values:
Now that youve added a coolbar to your form and set its alignment as you want, how do you add bands to that coolbar? See the next topic for the details. Adding Bands To A CoolbarThe controls in a coolbar are usually organized into bands (and note that those controls can themselves contain controls, as when you place toolbars in a band). To add a band to a coolbar, just follow these steps:
You can also add a band to a coolbar at runtime with its Bands collection, because that collection supports the usual collection methods Add and Remove. For example, heres how we add a new band to a coolbar at runtime:
Private Sub Command1_Click()
Dim band5 As Band
Set band5 = CoolBar1.Bands.Add()
End Sub
Now that youve added bands to a coolbar, how do you install controls in those bands? Take a look at the next topic to get the details. Adding Controls To Coolbar BandsYou add controls to coolbar bands by setting the bands Child property. The Child property can only hold one child control, which you might think limits the power of coolbars, but in fact, that control can be a complete toolbar. If you fill a coolbars bands with toolbar controls, users can arrange and slide those toolbars around as they like. To add a control to a coolbar band, follow these steps:
You can also set a bands Child property at runtime, as in this example where we set the control in the coolbars first band to Toolbar1:
Private Sub Command1_Click()
Set CoolBar1.Bands(1).Child = Toolbar1
End Sub
Handling Coolbar Control EventsYouve set up the coolbar you want and placed a few toolbars in the various bands of that coolbar. Now how do you handle button clicks in those toolbars (or other controls youve place in a coolbars bands)? Handling events from controls in coolbar bands is easyjust connect event handlers to those controls as you normally would (in other words, if they werent in a coolbar). Heres an example where weve added a toolbar, Toolbar1, to a coolbar. You can add buttons to the toolbar as you would normallyjust open the toolbars property pages and use the Insert Button button. To handle Click events for those button, you just double-click the toolbars buttons at design time, which opens the matching Click event handler: Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button) End Sub Then you just proceed as you would in a normal toolbar, such as adding this code where we indicate to users which button theyve clicked:
Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
MsgBox "You clicked button " & Button.Index
End Sub
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |