Page 1 of 1

trackbar status on release!

Posted: Thu Aug 11, 2005 1:31 pm
by thefool
Hi! When i have a standard event for a trackbar, even if i hold down the mouse on the trackbar and drags, the events are sent to it. How can i make an event only occour when the trackbar is released from a "draggin' "

Thanks.

Re: trackbar status on release!

Posted: Thu Aug 11, 2005 1:35 pm
by PB
This works... try it with and without the GetAsyncKeyState command! :)

Code: Select all

If OpenWindow(0,200,200,450,200,#PB_Window_SystemMenu,"test") 
  CreateGadgetList(WindowID()) 
  TrackBarGadget(1,10,10,200,30,1,10,#PB_TrackBar_Ticks)
  TextGadget(2,10,50,50,20,"1")
  Repeat 
    ev=WaitWindowEvent()
    If ev=#PB_Event_Gadget And GetAsyncKeyState_(#VK_LBUTTON)=0
      SetGadgetText(2,Str(GetGadgetState(1)))
    EndIf
  Until ev=#PB_EventCloseWindow 
EndIf

Posted: Thu Aug 11, 2005 1:39 pm
by thefool
works perfectly! thanks a lot :)

Posted: Sat May 27, 2006 5:36 pm
by Joakim Christiansen
Just what I need! :D
Why don't we have features like that in PureBasic 4? :cry:

Posted: Sat May 27, 2006 11:20 pm
by dagcrack
Because you're supossed to write them?.
I thought thats what programming was all about :wink:

Posted: Sun May 28, 2006 10:40 am
by srod
Here's another way:

Code: Select all

 Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
    Result = #PB_ProcessPureBasicEvents
    Select message
    Case #WM_HSCROLL
      If lParam=GadgetID(1) And wParam&$ffff=#SB_ENDSCROLL
        SetGadgetText(2,Str(GetGadgetState(1))) 
      EndIf
    EndSelect
    ProcedureReturn Result
  EndProcedure

If OpenWindow(0,200,200,450,200,"",#PB_Window_SystemMenu) 
  CreateGadgetList(WindowID(0)) 
  TrackBarGadget(1,10,10,200,30,1,10,#PB_TrackBar_Ticks) 
  TextGadget(2,10,50,50,20,"1") 
  SetWindowCallback(@MyWindowCallback()) 

  Repeat 
    ev=WaitWindowEvent() 
  Until ev=#PB_Event_CloseWindow 
EndIf