293 296




Visual Basic 6 Black Book:Scroll Bars And Sliders
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




Coordinating Scroll Bar Pairs
The Testing Department is calling again. The two scroll bars you’ve added to your SuperDuperWinBigCasino game look great, but there’s one problem: A pair of scroll bars straddle the user’s view of the roulette table in SuperDuperWinBigCasino, but when you scroll one, the other doesn’t move to match it. Can you fix that?
It’s common to have two scroll bars that perform the same scrolling action—one on either side of an image you’re 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 bar’s Value property. For example, say we have two vertical scroll bars, VScroll1 and VScroll2, that straddle an object they’re 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


That’s all there is to it. Now the scroll bars are coordinated.

Adding Scroll Bars To Text Boxes
How do you add scroll bars to text boxes? You use the text box’s 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 box’s 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:

•  VbSBNone—0; no scroll bars (the default)
•  VbHorizontal—1; horizontal
•  VbVertical—2; vertical
•  VbBoth—3; both vertical and horizontal

For example, we’ve added both horizontal and vertical scroll bars to the text box in Figure 9.5.


Figure 9.5  Adding scroll bars to a text box.
Creating And Using Flat Scroll Bars
A 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:

1.  Select the Project|Components menu item, and click the Controls tab in the Components box that opens.
2.  Select the Microsoft Flat Scrollbar Control item.
3.  Close the Components box by clicking on OK.
4.  The Flat Scroll Bar tool appears in the toolbox at this point. Add a flat scroll bar to your form in the usual way.
5.  Set the flat scroll bar’s Min, Max, SmallChange, and LargeChange values as you want them.
6.  Add the code you want to the scroll bar event you want, Change or Scroll. For example, here we add code to a flat scroll bar’s Change event, updating a text box with the setting of the scroll bar when the user is finished scrolling it:


Private Sub FlatScrollBar1_Change()
Text1.Text = "Scroll bar’s value: " & _
Str(FlatScrollBar1.Value)
End Sub



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.


Figure 9.6  Adding a flat scroll bar to a program.
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:

•  fsbVertical—0; vertical scroll bar
•  fsbHorizontal—1; horizontal scroll bar


TIP:  You can actually make a flat scroll bar appear 3D by setting its Appearance property. This property can take these values: fsb3D (whose value is 0), fsbFlat (value 1), and fsbTrack3D (value 2).

Customizing Flat Scroll Bar Arrows
Flat 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:

•  fsbBoth—0; enable both arrows
•  fsbLeftUp—1; enable left/up arrow
•  fsbRightDown—2; enable right/down arrow

For example, we set the flat scroll bar’s Arrows property to fsbLeftUp at design time in Figure 9.7, which means the right button is disabled.

Figure 9.7  Disabling the right arrow button in a flat scroll bar.
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






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