SLIDER

Like a spin, the slider also deals with numeric values. A slider has a shaft, and a knob that can be "grabbed" with the mouse (ie, by placing the mouse pointer over the knob, and pressing and holding down the mouse button) and moved along the shaft. The numeric value of the slider will change as the knob moves, with the far left position being the minimum value and the far right position being the maximum value of the slider. Alternately, when a slider has the focus (ie, it has a dotted outline around it), the knob can be moved with the left and right arrow keys. Furthermore, if the mouse is clicked to either side of the knob (but not on the knob itself), the value will increment or decrement (depending upon which side of the knob the mouse was clicked).


Uses

Allows the user to cycle through a wide range of numeric values very quickly, albeit hard to pinpoint specific settings, and therefore is more appropriate to use for setting parameters where very fine adjustments aren't as important as being able to quickly cycle through a large range.


Styles

Shortcut The Shortcut box lets you enter a keyboard shortcut that will automatically select this control whenever the user presses that shortcut.

A SLIDER must be created with one of the following 2 styles for its Orientation:

Horizontal Orients the slider horizontally.
Vertical Orients the slider vertically.

A SLIDER must also be created with one of the following 3 styles for Tick Marks:

Left For a HORIZONTAL slider, displays tick marks above the slider. For a VERTICAL slider, displays tick marks on the left.
Right For a HORIZONTAL slider, displays tick marks below the slider. For a VERTICAL slider, displays tick marks on the right.
Both For a HORIZONTAL slider, displays tick marks above and below the slider. For a VERTICAL slider, displays tick marks on the left and right.

In addition to the above, the slider may have any, all, or none of the following styles:

Auto ticks (AUTO) The slider has a tick mark for each increment in its range of values. These tick marks are added automatically when your script sends a SETRANGE message to the control. You can't send SETTIC messages to specify the position of the tick marks if you use this style. Send a CLEARTICS message instead.
No ticks (NOTICKS) Tick marks are not displayed.
Select Range (RANGE) Displays a selection range. When a slider has this style, the tick marks at the starting and ending positions of a selection range are displayed as triangles (instead of vertical dashes) and the selection range is highlighted. For example, selection ranges might be useful in a simple scheduling application. The user could select a range of tick marks corresponding to hours in a day to identify a scheduled meeting time.
No thumb (NOTHUMB) Slider knob is not displayed.
Fixed length (FIXED) The length of the slider remains the same even if you change the selection range.
Tool tip value (TIPS) A tool tip is created for the slider which shows its current value.
No Sibling (NOSIBLING) Prevents this control from drawing into any overlapping controls.
Group Marks this control as the first of a group of controls in which the user can move from one control to the next with the arrow keys. All subsequent controls (after this first control) belong to the same group up to the next control that has its GROUP flag set. (ie, One group ends where the next begins).
Tabstop The user can move to this control using the TAB key.
Disabled Control is initially disabled. You can later enable it with a call to GuiSetCtlPlacement.
Hide Control is hidden. You can later make it visible with a call to GuiSetCtlPlacement.
Border Has a border.


Extra styles

A SLIDER can have the following extra styles:

Buddy Uses the previously added ENTRY or TEXT control in the window to automatically print out the current value of the slider. Do not use this style if you plan to manually set a SLIDER's buddy window with GuiAddCtlText.
Delay While the user is moving a slider with the mouse, it will repeatedly cause a series of THUMBTRACK events for the slider (ie, constant update during slider movement). The DELAY flag filters out these events. This is useful if you don't need to receive constant updates of the slider movement, but rather, are concerned only with its final value. In this case, you will set DELAY style and handle the THUMBTRACK event.
Quiet Do not report any events for this control.
Modal Frame (MODALFRAME) Has a double border.
Static Edge (STATICEDGE) Has a three-dimensional border intended to be used for windows that do not accept user input.
Client Edge (CLIENTEDGE) Has a 3D look comprised of a border with a sunken edge.
Accept files (FILES) Accepts drag-and-drop files (ie, the DROPFILES event).
Transparent The control is to be transparent. Any controls that are beneath this one are not obscured.


Events

A SLIDER generates the following events:

Event name When it occurs
THUMBTRACK The user has dragged the slider knob (with the mouse) to a new position.
THUMBPOSITION The user has released the mouse after dragging the slider knob.
LINEUP The user has pressed the UP or LEFT arrow key to decrement the control (toward its low limit).
LINEDOWN The user has pressed the DOWN or RIGHT arrow key to increment the control (toward its high limit).
PAGEUP The user has pressed the PAGEUP key to move the control toward its low limit. Or, the user clicked on the slider's shaft above or to the left of the knob.
PAGEDOWN The user has pressed the PAGEDOWN key to move the control toward its high limit. Or, the user clicked on the slider's shaft below or to the right of the knob.
TOP The user has pressed the HOME key to set the control to its low limit.
BOTTOM The user has pressed the END key to set the control to its high limit.
ENDTRACK The user has released the PAGEUP, PAGEDOWN, HOME, END, or arrow keys.
DRAW Custom drawing may need to be done for the control.
RELEASE The user has released the slider knob.


REXX Variable

A SLIDER must have a REXX variable associated with it. Before opening the window which contains the SLIDER, you must set this variable's value to the desired value (ie, knob position). If the slider has the RANGE style, then you must set the variable to two numbers, the low range and the high range of the selection, each separated by a space.


Dynamically add/remove a SLIDER

You can dynamically add a SLIDER to an already open window by calling GuiAddCtl. You must pass a line that describes the control. The format for this line is:

SLIDER X, Y, Width, Height, Styles, ExtraStyles, VariableName, Accelerator, LowLimit HighLimit
X and Y is the position of the top left corner of the control, relative to the window's top left corner.

Width and Height are the size of the control, in DLUs.

Styles and ExtraStyles are those listed above, with each style separated by a | character.

VariableName is the variable name to be associated with the control.

Accelerator is the keyboard shortcut that causes the control to be selected for user input.

LowLimit is the lowest numeric value that the slider can be set to. HighLimit is the highest numeric value that the slider can be set to.

Before adding a slider, you should set its associated REXX variable to the desired position of the knob (ie, the desired numeric value).

For example, here we add a SLIDER at an X Y position of 10, 10, with a width and height of 80 and 20, with the style AUTO, extra styles of CLIENTEDGE and QUIET, a REXX Variable name of MySlider, a low limit of -10 and a high limit of 20. We set its value to 1 (ie, checked).

MySlider = 1

error = GuiAddCtl("SLIDER 10,10,80,20, AUTO, CLIENTEDGE|QUIET, MySlider,, -10 20")
You can dynamically remove a SLIDER by calling GuiRemoveCtl. Here we remove the above slider:
error = GuiRemoveCtl("MySlider")

Change a SLIDER's buddy window.

You can change a SLIDER's buddy window by calling GuiAddCtlText. You pass the REXX variable name of the slider, and then a second arg which is the REXX variable name (or handle) associated with the buddy window. Here we change the above slider's buddy window to the control associated with the variable MyTextControl:

error = GuiAddCtlText("MySlider", "MyTextControl")
Note: The buddy window should be a TEXT control type.

After you set the buddy window, then the slider's current value will be displayed in that buddy window.


Change a SLIDER's value

You can dynamically change a SLIDER's value by calling GuiSetCtlValue. You first set its associated REXX variable to the desired value, and then call GuiSetCtlValue, passing that variable name. For example, here we set the above slider to the value 5:

MySlider = 5
error = GuiSetCtlValue("MySlider")
Note: If a SLIDER has the RANGE style, then you must set the low and high points of the selection. For example, here we set the slider to the selected range from 0 to 5:
MySlider = "0 5"
error = GuiSetCtlValue("MySlider")


Query a SLIDER's value

You can query a SLIDER's value by calling GuiGetCtlValue. This will set its associated REXX variable to the control's current value. For example, here we query the above slider:

error = GuiGetCtlValue("MySlider")
IF error == "" THEN SAY "Slider value:" MySlider
Note: If a SLIDER has the RANGE style, the low and high points of the selection are returned in the variable (separated by a space).


Change a SLIDER's range

You can change a SLIDER's range. To change the low range value, send a SETRANGEMIN message. For the third arg, pass a 1 to redraw the slider, or 0 if not. For the fourth arg, pass the desired minumum range. Here we set the minimum range to 10:

error = GuiSendMsg("MySlider", "SETRANGEMIN", 1, 10)

To change the high range value, send a SETRANGEMAX message, similiar to above.


Change a SLIDER's tic marks

You can change a SLIDER's tic marks. If using the AUTO style, then send a SETTICFREQ message. For the third arg, pass the desired frequency. For example, if you pass a two, a tick mark is displayed for every other increment in the SLIDER's range. (NOTE: The default value is 1). For the fourth arg, pass the position of the tic mark. This must be a positive value.

If not using the AUTO style, then you can set your own tic marks by sending a series of SETTIC messages (ie, one SETTIC per tic mark). For the fourth arg, pass the desired position of the tic mark. (NOTE: The slider automatically has tic marks at its lowest and highest position, so you do not need to set tic marks there). You can omit the third arg.

To remove the tic marks, send a CLEARTICS message with no additional args.