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 youve added to your program, SuperDuperTextPro, look terrific. But why doesnt 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 bars LargeChange property (see also the next topic, which deals with the SmallChange property). For example, if youve set the scroll bars 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.
Heres 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 bars 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).
Ive 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 bars 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 bars 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 its part of your programs 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 Bars Current Value
Youve added the scroll bars you need to a program and set their Min, Max, SmallChange, and LargeChange properties, but youd like to add one more touch. When your program first displays the scroll bars, youd 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 bars setting. You can set this value at either design time or runtime, and you can set it to read a scroll bars 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.
Heres an example. In this case, were 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 289220 28901 (287)285 289SHSpec 289 6307C24 ARC Breaks and the Comm CycleNuestro Circulo 287 Movsa Feigin289 291więcej podobnych podstron