Just a snippet I made for a larger program. Use it for what its worth. (edit, this was suppose to be code snippets board)
Rem Project: Dark Basic Pro Project
Rem Created: Monday, April 16, 2012
Rem Phaelax
Rem ***** Main Source File *****
Type SliderObject
focus as boolean
offset as integer
thumb as integer
value as float
Endtype
dim sliders(1) as SliderOBject
Global _MFlag = 0
Global _MClick = 0
do
cls
_MClick = mouseclick()
slider(1, 200,100, 200, 20, 0, 50)
if _MClick > 0 : _MFlag = 1 : else : _MFlag = 0 : endif
loop
function slider(id, x, y, width, height, minVal, maxVal)
ink rgb(255,255,255),0
text x-text width(str$(minVal))-2, y, str$(minVal)
text x+width+2, y, str$(maxVal)
center text x+sliders(id).thumb, y-text height(" ")-2, str$(sliders(id).value)
ink rgb(110,244,2), 0
box x, y, x+width, y+height
tx = sliders(id).thumb
ink rgb(255,255,0), 0
box x+tx, y, x+tx+height, y+height
if _MClick = 1
if _MFlag = 0
if mouseHotspot(x+tx, y, x+tx+height, y+height) = 1 and sliders(id).focus = 0
sliders(id).focus = 1
sliders(id).offset = mousex() - sliders(id).thumb
endif
_MFlag = 1
endif
if sliders(id).focus = 1
sliders(id).thumb = mousex() - sliders(id).offset
if sliders(id).thumb < 0 then sliders(id).thumb = 0
if sliders(id).thumb > width-height then sliders(id).thumb = width-height
t# = sliders(id).thumb / (width-height+0.0)
sliders(id).value = minVal + (maxVal - minVal)*t#
endif
else
sliders(id).focus = 0
endif
endfunction
function mouseHotspot(x1, y1, x2, y2)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2 then exitfunction 1
endfunction 0
"You're not going crazy. You're going sane in a crazy world!" ~Tick