While Gadget Is Pressed?

Windows specific forum
ToastEater
User
User
Posts: 49
Joined: Tue Jul 25, 2006 5:07 pm

While Gadget Is Pressed?

Post 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
Sorry for my damn english
amour au PB et au traducteur de google d'ofcourse
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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?
BERESHEIT
ToastEater
User
User
Posts: 49
Joined: Tue Jul 25, 2006 5:07 pm

Post by ToastEater »

to have a Trackbar Desideing he position of a mp3 file playing
Sorry for my damn english
amour au PB et au traducteur de google d'ofcourse
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I'd like to help but I just can't understand what you're trying to accomplish, I'm sorry.
BERESHEIT
ToastEater
User
User
Posts: 49
Joined: Tue Jul 25, 2006 5:07 pm

Post 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.
Sorry for my damn english
amour au PB et au traducteur de google d'ofcourse
ToastEater
User
User
Posts: 49
Joined: Tue Jul 25, 2006 5:07 pm

Post by ToastEater »

Anybody ? :( i can't get my Track button to my timer to work :(
Sorry for my damn english
amour au PB et au traducteur de google d'ofcourse
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

i am working on a solution. it might be one more day. OK?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
ToastEater
User
User
Posts: 49
Joined: Tue Jul 25, 2006 5:07 pm

Post by ToastEater »

@Sparkie
Excatly what i needed thanks man :D
@LocalMotion34
:) toolate thanks anyway :wink:
Sorry for my damn english
amour au PB et au traducteur de google d'ofcourse
Post Reply