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
Creating Slider Controls
The Aesthetic Design Department is on the phone again. Theyve heard about slider controls in Visual Basic and like their look. Is there any way you can add them to your program, SuperDuperTextPro?
Adding a slider to a program is easy; just 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 Windows Common Controls item.
3. Close the Components box by clicking on OK.
4. The Slider tool appears in the toolbox at this point. Add a slider to your form in the usual way.
5. Set the sliders Orientation property to ccOrientationHorizontal (value 0, the default) or ccOrientationVertical (value 1) to specify the orientation you want.
6. Set the sliders Min, Max, SmallChange, and LargeChange values as you want them.
7. Set the sliders TickFrequency property to the number of units between tics on the sliders scale.
8. Add the code you want to the slider event you want, Change or Scroll. For example, here we add code to a sliders Change event, setting the blue color of a text box, Text1, to match the sliders setting, using the Visual Basic RGB function:
Private Sub Form_Load()
Slider1.Max = 255
Slider1.Min = 0
End Sub
Private Sub Slider1_Click()
Text1.BackColor = RGB(0, 0, Slider1.Value)
End Sub
Running this program yields the result you see in Figure 9.8. Now were using sliders in Visual Basic.
Figure 9.8 Adding a slider to a program.
Setting A Sliders Orientation
Like scroll bars, sliders can be horizontal or vertical, but unlike scroll bars, horizontal and vertical sliders are not two different controls. Instead, you set a sliders Orientation property to make it horizontal or vertical.
You can set the Orientation at design time or run-time; this property takes these values:
ccOrientationHorizontal (value 0, the default) orients the slider horizontally.
ccOrientationVertical (value 1) orients the slider vertically.
Can you change a sliders orientation in code? You certainly can. In this example, we make a sliders orientation vertical when the user clicks a button:
Private Sub Command1_Click()
Slider1.Orientation = ccOrientationVertical
End Sub
TIP: Besides reorienting sliders, you can move them around a form using their Move method.
Setting A Sliders Range
Youve added a new slider to your environment control program to let users set the temperature they want in their homes, but now they have a complaint. Why does the slider return values of up to 32,767 degrees?
Its time to reset the sliders range of possible values, and you use the Min (default value 0) and Max (default value 10) properties to do that. You can set a sliders range at design time or runtime.
For example, heres how we set a sliders range to a more reasonable span of temperatures:
Private Sub Form_Load()
Slider1.Max = 90
Slider1.Min = 50
End Sub
After setting the Min and Max properties, youll probably want to set the sliders tick frequency so the ticks on the sliders scale look appropriate for the new range (see Adding Ticks to a Slider in this chapter).
Setting Up Slider Groove Clicks
Besides dragging the knob along the groove in a slider, you can click the groove itself to move the knob (just as you can click the area of a scroll bar between the thumb and arrow buttons). The amount the knob moves each time the user clicks the groove is set with the sliders LargeChange property (just as it is in scroll bars). The default value for this property is 5.
You can set the LargeChange property at design time or runtime. For example, heres how we set a sliders LargeChange property to 5 when the form containing the slider first loads:
Private Sub Form_Load()
Slider1.Max = 255
Slider1.Min = 0
Slider1.LargeChange = 5
End Sub
If you change a sliders range of possible values (in other words, the Min and Max properties), keep in mind that you might also have to change the LargeChange property as well. For example, if you change the possible range of slider values from 0 to 32767 to 1 to 100 but leave LargeChange at 4096, theres going to be a problem when the user clicks the sliders groove.
TIP: Sliders also have a SmallChange property, but this seems to be one of the mystery properties you run across occasionally in Visual Basic, because there just is no way to use it in a slider. (Even looking it up in the Visual Basic documentation reveals nothingits undocumented, although it appears in the Properties window.) When you click a sliders groove, the slider moves by the LargeChange amount, but there arent any arrow buttons in sliders to cause SmallChange events.
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:
296 299296 299299 22299 25296 297293 296readme (299)291 296296 15296 05299 13więcej podobnych podstron