TSlider

Fuente: source/classes/slider.prg

Inherits from: TControl

TSlider provides a trackbar / slider control for selecting a numeric value by dragging a thumb along a track. It supports horizontal and vertical orientation, tick marks, snap-to-grid (exact) positioning, and a slim style with a colored thumb.

Command Syntax

@ nRow, nCol SLIDER oSld VAR nValue RANGE nMin, nMax SIZE nW, nH PIXEL OF oWnd ;
   HORIZONTAL MARKS nMarks EXACT ON CHANGE bBlock

Key DATA Members

DATATypeDescription
lHorizontalLogicalHorizontal orientation (.T.) or vertical (.F.)
nMinNumericMinimum value of the slider range
nMaxNumericMaximum value of the slider range
nMarksNumericNumber of tick marks along the track (0 = no marks)
lExactLogicalSnap the thumb to the nearest tick mark
nClrBtnNumericColor of the slider thumb button
lSlimStyleLogicalRender with a slim track and colored thumb
nDirectionNumericTick mark direction (1=top, 2=left, 3=bottom, 4=right)

Methods

MethodDescription
New( nRow, nCol, bSetGet, lHorizontal, lDirect1, lDirect2, nMin, nMax, nMarks, lExact, oWnd, bChange, bPos, nWidth, nHeight, lPixel, cMsg, nClrFore, nClrBack, nClrBtn, lDesign, lUpdate, lSlim )Create a new TSlider control
ReDefine( nId, bSetGet, lHorizontal, lDirect1, lDirect2, nMin, nMax, nMarks, lExact, oWnd, bChange, bPos, cMsg, nClrFore, nClrBack, nClrBtn, lUpdate, lSlim )Redefine from dialog resource
Set( nVal )Programmatically set the slider to a value
Change()Execute bChange code block with the current value
Default()Recalculate positions and redraw

Examples

Volume Slider (0-100)

#include "FiveWin.ch"

function Main()

   local oWnd, oSld, nVolume := 50

   DEFINE WINDOW oWnd TITLE "Volume Slider" SIZE 400, 150

   @ 40, 30 SLIDER oSld VAR nVolume RANGE 0, 100 ;
      SIZE 300, 30 PIXEL OF oWnd HORIZONTAL ;
      ON CHANGE oWnd:SetText( "Volume: " + Str( nVolume, 3 ) + "%" )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Selector with Tick Marks

#include "FiveWin.ch"

function Main()

   local oWnd, oSld, nOption := 3, aOpts := { "Low", "Med", "Norm", "High", "Max" }

   DEFINE WINDOW oWnd TITLE "Speed Selector" SIZE 400, 150

   @ 40, 30 SLIDER oSld VAR nOption RANGE 1, 5 ;
      SIZE 300, 30 PIXEL OF oWnd HORIZONTAL ;
      MARKS 5 EXACT ;
      ON CHANGE oWnd:SetText( "Speed: " + aOpts[ nOption ] )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También