[REBOL] Re: Skinz 0.2 Volume Control (The follow along tutorial :)
From: greggirwin:mindspring at: 26-Feb-2002 9:39
Hi Terry,
<< Ok, need a slider that provides a value of 0 on the bottom, to 255 on the
top. Once the slider stops moving, must fill in n below and make this
call...
send-message winamp-hwnd WM_USER n 122 >>
map-slider-to-value: func [
"Converts a slider value between 0 and 1 to a value within a range."
value [number!] "A value between 0 and 1."
min-val [number!] "The minimum range value (if value = 0)."
max-val [number!] "The maximum range value (if value = 1)."
][
max-val - min-val * value + min-val
]
map-value-to-slider: func [
"Converts a value within a range to a slider value between 0 and 1."
value [number!] "A value between min-val and max-val."
min-val [number!] "The minimum range value. Equals a slider value of
0."
max-val [number!] "The maximum range value. Equals a slider value of
1."
][
value - min-val / (max-val - min-val)
]
view layout [
sld-vol: slider [
vol-val: to-integer map-slider-to-value sld-vol/data 255 1
print vol-val
]
]
You can use map-value-to-slider to preset the slider to the correct position
if you can read the current volume setting from WinAmp.
sld-vol/data: map-value-to-slider vol-current-value 255 1
--Gregg