|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Coordinating Scroll Bar PairsThe Testing Department is calling again. The two scroll bars youve added to your SuperDuperWinBigCasino game look great, but theres one problem: A pair of scroll bars straddle the users view of the roulette table in SuperDuperWinBigCasino, but when you scroll one, the other doesnt move to match it. Can you fix that? Its common to have two scroll bars that perform the same scrolling actionone on either side of an image youre scrolling, for example. The user should be able to scroll either scroll bar and have the other one match. Keeping scroll bars coordinated is easy. All you have to do is make sure that when one scroll bar has a Change event, you update the other scroll bars Value property. For example, say we have two vertical scroll bars, VScroll1 and VScroll2, that straddle an object theyre in charge of scrolling. You can update VScroll2 when VScroll1 changes this way:
Private Sub VScroll1_Change()
VScroll2.Value = VScroll1.Value
End Sub
And you can update VScroll1 when VScroll2 changes:
Private Sub VScroll2_Change()
VScroll1.Value = VScroll2.Value
End Sub
Thats all there is to it. Now the scroll bars are coordinated. Adding Scroll Bars To Text BoxesHow do you add scroll bars to text boxes? You use the text boxs ScrollBars property instead of using actual scroll bar controls, but we include this topic here anyway because this is a natural chapter to turn to with this question. First, make sure you set the text boxs MultiLine property to True, because only multiline text boxes support scroll bars. Next, decide what kind of scroll bars you want on the text box: horizontal, vertical, or both, and set the ScrollBars property to match. That property can take these values:
For example, weve added both horizontal and vertical scroll bars to the text box in Figure 9.5.
Creating And Using Flat Scroll BarsA relatively new control is the flat scroll bar control. This control can function just like any other scroll bar, except that it appears flat, not 3D. To add flat scroll bars to a form, follow these steps:
Run the program now, as shown in Figure 9.6. As you can see in that figure, the flat scroll bar does indeed appear flat, but it functions like any other scroll bar when the user scrolls it.
Unlike standard scroll bars, you can change the orientation of a flat scroll bar with its Orientation property. The Orientation property can take these values:
Customizing Flat Scroll Bar ArrowsFlat scroll bars have one advantage over standard scroll bars: you can disable either arrow button selectively in a flat scroll bar using the Arrows property. You set the Arrows property to one of these values:
For example, we set the flat scroll bars Arrows property to fsbLeftUp at design time in Figure 9.7, which means the right button is disabled.
You can also work with the Arrows property in code like this, where we enable both arrow buttons:
Private Sub Command2_Click()
FlatScrollBar1.Arrows = fsbBoth
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. |