Page 1 of 1

While Gadget Is Pressed?

Posted: Fri Aug 18, 2006 2:02 am
by ToastEater
Ima currectly making a quite big project there controls lot of files.
Within there have to be a MP3.
Its working perfectly with the mciSendString but there is still one problem, with the Trackbar for change the time.
I need something about when a Gadget is hold down it wont go futhure in the code.
sorry bad explanation bad english here - my bad.
Something like this

Code: Select all

...
...
...

Repeat
  
  Event = WindowEvent()
  Select Event
  case bla
     ...
  case otherbla
    ....
    Case #PB_Event_Gadget
      Select EventGadget()
          Case MyTrack
              While Track_Is_Press
                   ; Do nothing
                   Delay(20) ; For flickking
              Wend
                   ;  Seek in the mp3 of the Track
      endselect
   EndSelect
Until Event = #PB_Event_CloseWindow

Sorry for bad english hope you understand.
Thanks a bunch already
Regards

Posted: Fri Aug 18, 2006 4:20 am
by netmaestro
I can't understand - if you trap the loop while the trackbar is pressed, you can't move the trackbar, rendering it useless. What exactly are you trying to prevent happening?

Posted: Fri Aug 18, 2006 5:37 am
by ToastEater
to have a Trackbar Desideing he position of a mp3 file playing

Posted: Fri Aug 18, 2006 5:46 am
by netmaestro
I'd like to help but I just can't understand what you're trying to accomplish, I'm sorry.

Posted: Fri Aug 18, 2006 6:13 am
by ToastEater
@NetMaestro I'd like to help but I just can't understand what you're trying to accomplish, I'm sorry.
I know Thanks :)
.


okay i past a bit of my code

Code: Select all

Select EventGadget()
  Case _mp3timetrack
    mciseek(GetGadgetState(_mp3timetrack))
EndSelect
Very simply if the _mp3timetrack have been touch it will change the playing too. But when use it it just make a joke outta the track.

Posted: Sat Aug 19, 2006 12:53 pm
by ToastEater
Anybody ? :( i can't get my Track button to my timer to work :(

Posted: Sat Aug 19, 2006 2:48 pm
by localmotion34
i am working on a solution. it might be one more day. OK?

Posted: Sat Aug 19, 2006 3:03 pm
by Sparkie
Hi ToastEater. Is this what you are looking for? If you move the Trackbar with the left mouse button or any of the Up/Down/Left/Right keys, you bypass the call to mci3seek until the mouse button or key has been released. This works on Windows only as it uses API (GetAsyncKeyState_).

Code: Select all

#mp3timetrack = 1

If OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  TextGadget(0, 10, 90, 280, 20, "Move the Trackbar")
  TrackBarGadget(#mp3timetrack, 10, 120, 280, 20, 0, 30, #PB_TrackBar_Ticks)
  SetGadgetState(#mp3timetrack, 20)
  Repeat
    event = WaitWindowEvent()
    Select EventGadget() 
      Case #mp3timetrack 
        If GetAsyncKeyState_(#VK_LBUTTON) Or GetAsyncKeyState_(#VK_UP) Or GetAsyncKeyState_(#VK_DOWN) Or GetAsyncKeyState_(#VK_LEFT) Or GetAsyncKeyState_(#VK_RIGHT)
          ;...Do nothing while moving Trackbar
          SetGadgetText(0, "Do nothing while Trackbar is moving")
        Else
          ;...Seek and play mp3
          SetGadgetText(0, "It is now ok to seek and play mp3")
          ;mciseek(GetGadgetState(_mp3timetrack)) 
        EndIf
    EndSelect 
  Until event = #PB_Event_CloseWindow
EndIf
End

Posted: Sun Aug 20, 2006 1:52 am
by ToastEater
@Sparkie
Excatly what i needed thanks man :D
@LocalMotion34
:) toolate thanks anyway :wink: