Trackbar range question

Just starting out? Need help? Post your questions and find answers here.
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Trackbar range question

Post 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
1.3AMD, 2x 256 sdr, 32 AGP
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Trackbar range from 0 - 10000

how do i get

TRACKBAR..

0---------------100-------------200
Using the famous three-rule.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post 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! :wink:

(Topic edited)
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Post by Bong-Mong »

i wanna use trackbar for audio balance control, but range is out
1.3AMD, 2x 256 sdr, 32 AGP
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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 :wink: :arrow:
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post 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
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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

:D
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Post by Bong-Mong »

your boys/girls are good man.. thanks once again
1.3AMD, 2x 256 sdr, 32 AGP
Post Reply