287 289




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




Setting Up Scroll Bar Clicks (Large Changes)
The Testing Department is calling again. The scroll bars you’ve added to your program, SuperDuperTextPro, look terrific. But why doesn’t anything happen when the user clicks the scroll bar itself, in the area between the thumb (the scroll box) and an arrow button? You ask, should something happen? They say, yes.
When the user clicks the scroll bar itself, not the thumb and not an arrow button, the thumb should move in that direction by the amount set by the scroll bar’s LargeChange property (see also the next topic, which deals with the SmallChange property). For example, if you’ve set the scroll bar’s range to be 1 to 100, a reasonable LargeChange setting would be 10. You can set the LargeChange property at design time or at runtime.
Here’s an example where we set the LargeChange property for two scroll bars, a horizontal one and a vertical one:


Private Sub Form_Load()
VScroll1.Min = 1
VScroll1.Max = 100
VScroll1.LargeChange = 10

HScroll1.Min = 1
HScroll1.Max = 100
HScroll1.LargeChange = 10
End Sub


Now when the user clicks the scroll bar between the thumb and arrow buttons, the scroll bar’s value will increase or decrease by 10.

Note that on some occasions, you should change the LargeChange property while a program is running. For example, if you let the user scroll through a document with this property, setting it to 1, and the user loads in a 30,000-line document, it might be wise to change the value of this property, such as making the large change, say, 5 percent of the total, or 1,500 lines.
Setting Up Scroll Bar Arrow Clicks (Small Changes)
As far as the user is concerned, there are three ways to change the setting of a scroll bar: by moving the thumb (the scroll box), by clicking the area of the scroll bar between the thumb and an arrow button, and by clicking an arrow button. When the user clicks an arrow button, the thumb moves by an amount stored in the SmallChange property (see also the previous topic, which deals with the LargeChange property).
I’ve known someone who thought the SmallChange property was a joke because its name can be interpreted humorously, but it exists all right. When the user clicks a scroll bar’s arrow, the setting of the scroll bar is incremented or decremented (depending on which arrow was clicked) by the value in the SmallChange property.
You can set a scroll bar’s SmallChange property at design time or at runtime. Here we set the SmallChange property for two scroll bars, a horizontal one and a vertical one:


Private Sub Form_Load()
VScroll1.Min = 1
VScroll1.Max = 100
VScroll1.SmallChange = 1

HScroll1.Min = 1
HScroll1.Max = 100
HScroll1.SmallChange = 1
End Sub


Now when the user clicks the arrow buttons, the setting of the scroll bar will change by 1.

Note that on some occasions, you should change the SmallChange property while a program is running. For example, if you let the user scroll through a document with this property, setting it to 1, and the user loads in a 30,000-line document, it might be wise to change the value of this property to, say, something like 1 percent of the total, or 300 lines.

TIP:  This is one of those values that you should test yourself, because it’s part of your program’s feel. I know of a graphics program that scrolls exactly one pixel at a time when you click the arrow buttons in the scroll bars next to an image. Such a thing is annoying and gives users the impression that your program is unresponsive and hard to use.

Getting A Scroll Bar’s Current Value
You’ve added the scroll bars you need to a program and set their Min, Max, SmallChange, and LargeChange properties, but you’d like to add one more touch. When your program first displays the scroll bars, you’d like them to display a default value, which is right in the middle of their range. How do you set the setting of a scroll bar?
You use the Value property to set a scroll bar’s setting. You can set this value at either design time or runtime, and you can set it to read a scroll bar’s setting while the program is running. The Value property holds values that can be in the range spanned by the values in the Min and Max properties.
Here’s an example. In this case, we’re setting up two scroll bars, a horizontal one and a vertical one, and placing the thumb of each scroll bar in the center of the range when the scroll bar first appears by setting the Value properties this way:


Private Sub Form_Load()
VScroll1.Min = 1
VScroll1.Max = 100
VScroll1.LargeChange = 10
VScroll1.SmallChange = 1
VScroll1.Value = 50

HScroll1.Min = 1
HScroll1.Max = 100
HScroll1.LargeChange = 10
HScroll1.SmallChange = 1
HScroll1.Value = 50
End Sub


When the user makes a change in a scroll bar, you get the new setting from the Value property when the Change event is triggered (see the next topic).



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:
demo cgi 289
220 289
01 (287)
285 289
SHSpec 289 6307C24 ARC Breaks and the Comm Cycle
Nuestro Circulo 287 Movsa Feigin
289 291

więcej podobnych podstron