|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Its also easy to add a new status bar panel at runtimejust use the Panels collections Add method. Heres 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 youve added panels to the status bar, how do you display text in those panels? See the next topic. Displaying Text In A Status BarYouve added a new status bar to your program and added the panels you want to the status barbut how do you display text? The status bar control youve added doesnt seem to have a Text property. The text in a status bar is displayed in the status bars panels (unless the status bar is a simple status barsee Creating Simple Status Bars later in this chapterin which case you use the status bars SimpleText property). Displaying text in a status bars panels is easyjust select the panel you want to work with as the index into the status bars Panels collection, and use that panels Text property. Heres an examplein this case, well 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
Thats itthe result of this code appears in Figure 15.21. Now weve displayed text in a status bar.
The code for this example is located in the statusbar folder on this books accompanying CD-ROM. Displaying Time, Dates, And Key States In A Status BarThe 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:
See Figure 15.22 for a status bar showing the time.
Customizing A Status Bar Panels AppearanceYou 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. Heres how you can set the Bevel property:
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:
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:
Displaying Images In A Status BarThe 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:
Thats itnow when you run the program, the image youve selected appears in the panel youve chosen, as shown in Figure 15.23.
|
|
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. |