trackbar status on release!

Just starting out? Need help? Post your questions and find answers here.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

trackbar status on release!

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: trackbar status on release!

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

works perfectly! thanks a lot :)
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Just what I need! :D
Why don't we have features like that in PureBasic 4? :cry:
I like logic, hence I dislike humans but love computers.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Because you're supossed to write them?.
I thought thats what programming was all about :wink:
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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 
I may look like a mule, but I'm not a complete ass.
Post Reply