Visual Basic 6 Black Book:Toolbars, Status Bars, Progress Bars, And Coolbars
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Lets see an example. Insert a new button into a toolbar and set its Style property to tbrSeparator, as shown in Figure 15.8.
Figure 15.8 Adding a spacer to a toolbar.
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.
Figure 15.9 Using a separator in a toolbar.
TIP: Although toolbar separators just look like blank space, they count as buttons, which means that they have their own Index value. That means that you have to take separators into account when figuring a buttons Index value in your toolbar in order to handle it when its clicked.
Adding Images To Toolbar Buttons
The 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:
1. Right-click the image list control.
2. Select the Properties menu item.
3. Click the Images tab in the image controls property pages.
4. Click the Insert Picture button to insert the first image (you can browse through your hard disks and select the images you want).
5. Keep going until all the images have been added to the image control, then click on OK to close the property pages.
Now you need to associate the image control with the toolbar, and you do that in the toolbars property pages; just follow these steps:
1. Right-click the toolbar and select the Properties item to open the toolbars property pages, as shown in Figure 15.10.
Figure 15.10 Adding images from an image control to a toolbar.
2. Next, click the Buttons tab in the property pages, as shown in Figure 15.11.
Figure 15.11 Connecting images from an image control to toolbar buttons.
3. Enter the index of the image in the image control you want to connect to the first button in the box labeled Image (image lists are 1-based).
4. Keep going for the other buttons, entering the image control indices of the images you want to connect to those buttons.
5. Click on OK to close the property pages.
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
TIP: Visual Basic comes with the standard bitmaps youll find in Windows toolbarsjust check the common\graphics\bitmaps\offctlbr\small\color directory.
Adding Check (Toggle) Buttons To A Toolbar
The 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.
Figure 15.12 Making a toolbar button a check button.
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.
Figure 15.13 A check toolbar button at work.
Creating Button Groups In A Toolbar
You 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:
1. Open the toolbars property pages by right-clicking the toolbar and selecting the Properties item.
2. Click the Buttons tab.
3. Select the button in the button group, and set its style to tbrButtonGroup in the Style box, as shown in Figure 15.14.
Figure 15.14 Creating a button group in a toolbar.
4. Repeat Step 3 for the other buttons in the button group.
5. Click on OK to close the property pages.
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 Toolbar
The 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:
1. Right-click the toolbar, and select Properties in the menu that appears.
2. Click the Buttons tab in the property pages that open, as shown in Figure 15.15.
Figure 15.15 The toolbar property pages.
3. Insert a new button where you want the combo box to go.
4. Set the new buttons Style property to tbrPlaceholder in the box labeled Style. This means the button wont appeartherell only be a blank space, and well place our combo box there.
5. Set the width of the space you want to leave for the combo box by entering a twip (1/1440s of an inch) value in the box labeled Width: (Placeholder), as shown in Figure 15.15.
6. Close the property pages by clicking on OK.
7. Click the Combo Box Control tool in the toolbox, and draw a new combo box in the new space in the toolbar.
8. Add the items you want in the combo box in the Properties windows List property (or add items to the combo box at runtime).
9. Connect the code you want to the combo box. For example, here we respond to combo box clicks and text entry by displaying a message box:
Private Sub Combo1_Change()
MsgBox "You entered " & Combo1.Text
End Sub
Private Sub Combo1_Click()
MsgBox "You selected " & Combo1.Text
End Sub
Previous
Table of Contents
Next
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.
Wyszukiwarka
Podobne podstrony:
474 (2)Etefo 480 SLindex (480)474 477readme (474)01 (474)06 (480)480,17,artykul474 478ETHREL 480 SLwięcej podobnych podstron