485 489




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




It’s also easy to add a new status bar panel at runtime—just use the Panels collection’s Add method. Here’s an example where we add a panel to a status bar when the user clicks a command button:


Private Sub Command1_Click()
Dim panel5 As Panel
Set panel5 = StatusBar1.Panels.Add()
Panel5.Text = "Status: OK"
End Sub


Now that you’ve added panels to the status bar, how do you display text in those panels? See the next topic.

Displaying Text In A Status Bar
You’ve added a new status bar to your program and added the panels you want to the status bar—but how do you display text? The status bar control you’ve added doesn’t seem to have a Text property.
The text in a status bar is displayed in the status bar’s panels (unless the status bar is a simple status bar—see “Creating Simple Status Bars” later in this chapter—in which case you use the status bar’s SimpleText property). Displaying text in a status bar’s panels is easy—just select the panel you want to work with as the index into the status bar’s Panels collection, and use that panel’s Text property.
Here’s an example—in this case, we’ll display the program status, “OK”, in the first panel of the status bar (note that the Panels collection is 1-based) when the user clicks a command button, Command1:


Private Sub Command1_Click()
StatusBar1.Panels(1).Text = "OK"
End Sub


That’s it—the result of this code appears in Figure 15.21. Now we’ve displayed text in a status bar.


Figure 15.21  Displaying text in a status bar control.
The code for this example is located in the statusbar folder on this book’s accompanying CD-ROM.

Displaying Time, Dates, And Key States In A Status Bar
The Testing Department has sent you some email: the clock-watchers who use your SuperDuperDataCrunch program want a clock to watch. Can you add one to your program?
You can, and you can display it in the status bar. In fact, status bar controls are already set up to display common status items like key states and dates. To display one of those items, just right-click the status bar, select the Properties item in the menu that appears, click the Panels tab, select the panel you want to work with, and set the Style property in the box labeled Style to one of the following:

•  sbrText—0 (the default); text and/or a bitmap. Displays text in the Text property.
•  sbrCaps—1; Caps Lock key. Displays the letters “CAPS” in bold when Caps Lock is enabled, and dimmed when disabled.
•  sbrNum—2; Num Lock key. Displays the letters “NUM” in bold when the Num Lock key is enabled, and dimmed when disabled.
•  sbrIns—3; Insert key. Displays the letters “INS” in bold when the Insert key is enabled, and dimmed when disabled.
•  sbrScrl—4; Scroll Lock key. Displays the letters “SCRL” in bold when Scroll Lock is enabled, and dimmed when disabled.
•  sbrTime—5; time. Displays the current time in the system format.
•  sbrDate—6; date. Displays the current date in the system format.
•  sbrKana—7; Kana lock. Displays the letters “KANA” in bold when kana lock is enabled, and dimmed when disabled (this feature is enabled on Japanese operating systems only).

See Figure 15.22 for a status bar showing the time.


Figure 15.22  Displaying time in a status bar.
Customizing A Status Bar Panel’s Appearance
You can customize the appearance of the panels in a status bar with the Bevel, AutoSize, and Alignment properties. The Bevel property specifies whether the panel will have an inset bevel (the default), raised, or none at all. Here’s how you can set the Bevel property:

•  sbrNoBevel—0; the Panel displays no bevel, and text looks like it is displayed right on the status bar.
•  sbrInset—1; the Panel appears to be sunk into the status bar.
•  sbrRaised—2; the Panel appears to be raised above the status bar.

The AutoSize property determines how a panel will resize itself when its container (usually a form) is resized by the user. Here are the settings for the AutoSize property:

•  sbrNoAutoSize—0; None. No autosizing occurs. The width of the panel is always and exactly that specified by the Width property.
•  sbrSpring—1; Spring. When the parent form resizes and there is extra space available, all panels with this setting divide the space and grow accordingly. (The panels’ width never falls below that specified by the MinWidth property.)
•  sbrContents—2; Content. The panel is resized to fit its contents.

The Alignment property indicates how the text or image in a panel will align in the panel. The settings for the Alignment property are as follows:

•  sbrLeft—0; text appears left-justified and to the right of any bitmap.
•  sbrCenter—1; text appears centered and to the right of any bitmap.
•  sbrRight—2; text appears right-justified but to the left of any bitmap.

Displaying Images In A Status Bar
The Aesthetic Design Department is on the phone. How about adding a few images to the status bar? In fact, how about some animation for the user to watch while the program does other things? You think, is that possible?

Yes, it is, because status bar panels have a Picture property. To place an image in a status bar panel at design time, follow these steps:

1.  Right-click the status bar, and select the Properties item in the menu that appears.
2.  Click the Panels tab in the property pages that open.
3.  Select the panel you want to work with.
4.  Set the panel’s Picture property by clicking the Browse button in the box labeled Picture. You can set this property with an image file on disk.
5.  Close the property pages by clicking on OK.

That’s it—now when you run the program, the image you’ve selected appears in the panel you’ve chosen, as shown in Figure 15.23.


Figure 15.23  Displaying images in a status bar.



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:
485 489
489 Polska reklamaq51 874 4
485 Gordon Lucy Dziesiąta rocznica ślubu
411 489
489 Jaką metodę amortyzacji środków trwałych wybrać
485 486
RS 422 RS 485 Communication protocol user s guide(1)
482 485
06 (485)
485 488
05 (489)
482 485
index (485)
489 493

więcej podobnych podstron