Page 1 of 1
Trackbar range question
Posted: Fri Jan 09, 2004 12:29 pm
by Bong-Mong
Balance can range can be from -100 to 100 (-100 is full right, 0 is middle (normal mode) and 100 is full left).
Trackbar range from 0 - 10000
how do i get
TRACKBAR..
0---------------100-------------200
............................................^ Trackbar =100 in this positon
......................^ Trackbar =0 in this positon
^Trackbar =-100 in this positon
Posted: Fri Jan 09, 2004 12:39 pm
by Psychophanta
Trackbar range from 0 - 10000
how do i get
TRACKBAR..
0---------------100-------------200
Using the famous three-rule.
Posted: Fri Jan 09, 2004 12:47 pm
by Dare2
Is this what you're asking?
Code: Select all
..
TrackBarGadget(#TrakGadget, xPos, yPos, wide, High, 1, 200)
..
repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case #TrakGadget
result = 100 - GetGadgetState(#Gadget)
if result < 0
.. do lefter stuff
elseif result > 0
.. righter stuff
else
.. do zerostuff
endif
EndSelect
EndSelect
until eventID = #PB_EventCloseWindow
Or did I miss the point completely?
[EDIT]
Famous three rule?
Posted: Fri Jan 09, 2004 12:56 pm
by Danilo
@
Bong-Mong:
'how do.' in the topic says nothing. Would be kind of you if you
use a topic that says something about the contents, next time.
Thanks in advance!
(Topic edited)
Posted: Fri Jan 09, 2004 1:56 pm
by Bong-Mong
i wanna use trackbar for audio balance control, but range is out
Posted: Fri Jan 09, 2004 3:22 pm
by Psychophanta
Bong-Mong.
If trackbar understands range 0 to 10000 and you want to get -100 to 100, then you must to multiply by (2/100) what you get from trackbar position, and then substract 100 to the result.
What Danilo says is about to try to write a descriptive title for new TOPICS in the Forum. For example for this should be good: "How to get trackbar position relative...", because in that way it is easy to search and look a nice Forum

Posted: Fri Jan 09, 2004 4:15 pm
by ebs
@Dare2,
Actually, shouldn't the math be:
Code: Select all
result = GetGadgetState(#Gadget) - 100
That way, the max trackbar value of 200 gives 100, 100 gives 0 , and 0 gives -100.
Eric
Posted: Fri Jan 09, 2004 4:44 pm
by Dare2
Heya ebs,
I think you're right!

In fact I know you are.
Too much of my coding life at the mo is spent fixing *citcelsyd* code like the above, eg,
a > b instead of
a < b

Posted: Sat Jan 10, 2004 8:15 pm
by Bong-Mong
your boys/girls are good man.. thanks once again