|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Lets see an example. Insert a new button into a toolbar and set its Style property to tbrSeparator, as shown in Figure 15.8.
Now add other buttons, and click on OK to close the toolbars property pages. When you do, youll see that the separator puts some distance between the buttons, as shown in Figure 15.9.
Adding Images To Toolbar ButtonsThe Aesthetic Design Department is calling. Your new toolbar looks great, but it would look even better if you used images in the buttons and not text captions. How about it? You can give toolbar buttons if you place those images into an image list control. Image lists are Windows common controls just as toolbars are, so add an image list to a program now. To place the images you want in the buttons in the image list, follow these steps:
Now you need to associate the image control with the toolbar, and you do that in the toolbars property pages; just follow these steps:
When you run the program, the images appear in the toolbar. You can also connect an image control to a toolbar at runtime, using the toolbars ImageList property:
Private Sub Command1_Click()
Toolbar1.ImageList = ImageList1
End Sub
Adding Check (Toggle) Buttons To A ToolbarThe Testing Department is calling again: The toolbar youve added to your program, SuperDuperTextPro, is terrific, but theres one problem. One of the menu items, the Insert item, displays a checkmark next to it when the user toggles that mode on. Cant you add a checkmark to the Insert button in the toolbar as well? The way toolbars handle this problem instead of displaying checkmarks is to keep a button depressed once its been pressed. In this way, you can show toggle states. Lets take a look at an example. To make a toolbar button a check button, you must set its Style property to tbrCheck, and you do that in the toolbars property pages. Right-click the toolbar now and select the Properties item to open the property pages. Click the Buttons tab in the property pages, as shown in Figure 15.12.
Select the button you want to work with, and set its style to tbrCheck, as shown in Figure 15.12. Thats it. Now when the user clicks the button, it stays clicked, as shown in Figure 15.13, until the user clicks it again.
Creating Button Groups In A ToolbarYou may notice in some toolbars that a set of buttons are mutually exclusivefor example, if your word processor lets you align text to the right, left, and center with buttons in a toolbar, only one of those styles can be active at once. When the user clicks one, the others should toggle off. You can set up groups of mutually exclusive buttons in toolbars, just as you can with groups of option buttons (in fact, thats just what button groups in a toolbar resemble: a group of graphical [Style = 1] option buttons). To create a button group, just follow these steps:
Thats all it takes. Now the buttons youve placed together in a group will act together. When the user clicks one to select it, the others will toggle off (in other words, go back to their unselected position). Button groups can be very useful in a toolbarany time option buttons would come in handy in a toolbar, just use a button group instead. Adding Combo Boxes And Other Controls To A ToolbarThe Program Design Department is calling again. That shopping program youve written, SuperDuperGroceryStore4U, is nice, but what about listing the available groceries in a combo box in the toolbar. You wonder, how can you do that? You can add combo boxes or other controls to a toolbar easily; just set aside space in the toolbar by setting a buttons Style property to tbrPlaceholder. Here are the steps to follow to add a combo box to a toolbar:
|
|
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. |