A slider control displays a slider that looks like this:
---------------------------------
| -- |
| ----| |-------------------- |
| \/ |
---------------------------------
The user can use the mouse to move the slider to a new position:
---------------------------------
| -- |
| ----------------| |-------- |
| \/ |
---------------------------------
After the slider has been moved, we can get its new value and use it in our code; in this way, a slider works much like a scrollbar. Let's add a slider control to our ActiveX control Web page, calling it Slider1:
<HTML>
<HEAD>
<TITLE>OCX Control Page</TITLE>
</HEAD>
<BODY LANGUAGE = VBScript ONLOAD = "Page_Initialize">
<CENTER>
<H1>OCX Control Page</H1>
</CENTER>
.
.
.
<!- Slider>
<PRE>
--> Slider: <OBJECT CLASSID="clsid:373FF7F0-EB8B-11CD-8820-08002B2F4F5A"
HEIGHT=50 WIDTH=250 Change = Slider1_Change ID=Slider1></OBJECT>
</PRE>
.
.
.
When the user moves the slider, a Change event occurs, and we can catch it like this:
<SCRIPT LANGUAGE = VBScript>
Sub Page_Initialize
Cmd1.Caption = "Hello"
Frame1.Caption = "Frame"
Panel1.Caption = "Panel"
Grid1.Rows = 3
Grid1.Cols = 3
Grid1.Row = 1
Grid1.Col = 1
Grid1.Text = "5"
Graph1.GraphData = 2
Graph1.GraphData = 4
Graph1.GraphData = 5
Graph1.GraphData = 3
End Sub
--> Sub Slider1_Change
.
.
.
--> End Sub
</SCRIPT>
</BODY>
</HTML>
Our new slider appears in Figure 6.4. You can set the slider's range by setting its Min and Max properties. After the user moves the slider, a Change event occurs; you can find the slider's new value by checking its Value property. We'll put the slider to work soon. Now, however, let's look at the KeyState control.