Trackbar and SetGadgetState
Trackbar and SetGadgetState
I have a trackbar that is used as an indicator, ie, changed using SetGadgetState(). What EventType/#WM_???? tells me it has changed? I want to update a text control when the bars value changes, possibly from several places so I want to capture an event. Another situation is where a trackbar is used for both input and output (at different times).
Sorry, I didn't read the bit about SetGadgetState(). Back in a mo...
The following works here ok. Also on PB 4 -b11.
The following works here ok. Also on PB 4 -b11.
Code: Select all
REMOVED
I may look like a mule, but I'm not a complete ass.
dmoc, it's true the #TBM_SETPOS message doesn't seem to fire off any messages (at least at first glance). I guess the thing is, why would you need to intercept a message when your code is actually changing the track position anyhow? Surely you can set the contents of the text gadget at the same time?
I'll keep looking however.
I'll keep looking however.
I may look like a mule, but I'm not a complete ass.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
This works here:
Code: Select all
Procedure Callback(hwnd, message, wparam, lparam)
If message = #WM_VSCROLL
If wparam & $FFFFFFFF = #SB_ENDSCROLL
Debug "Changed!"
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,640,480,"VistaClock dll Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
TrackBarGadget(0,200,50,20,200,64,320,#PB_TrackBar_Vertical)
SetWindowCallback(@callback())
Repeat
EventID=WaitWindowEvent()
Until EventID=#PB_Event_CloseWindow
BERESHEIT
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
dmoc, one completely unsubtle approach is to subclass the TrackBar and intercept it's #WM_PAINT event.
It aint pretty though!
Code: Select all
Global oldproc
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Select Message
Case #WM_PAINT
Debug 1
EndSelect
ProcedureReturn CallWindowProc_(oldproc, WindowID, Message, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
TextGadget (3, 10, 40, 250, 20,"TrackBar Standard", #PB_Text_Center)
TrackBarGadget(0, 10, 60, 250, 20, 0, 10000)
ButtonGadget(1,10,10,100,20,"Click!")
oldproc=SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @MyWindowCallback())
SetGadgetState(0, 5000)
Repeat
ev=WaitWindowEvent()
Select ev
Case #PB_Event_Gadget
Select EventGadget()
Case 1
SetGadgetState(0, 6000)
EndSelect
EndSelect
Until ev = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.
My friends, the path you suggest is the path to madness
I speak now of only one control and one dependent control. But a time may come when there are many controls each of which beget yet more controls. And so a multitude of controls and message thus go forth and hence forth chaos shall rule the world.
You see now how important it is that we find an answer and save the world?

You see now how important it is that we find an answer and save the world?

The following avoids subclassing and only fires for the the specified trackbar.
However, I've no idea what message corresponds to 312!!!
However, I've no idea what message corresponds to 312!!!
Code: Select all
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case 312
If lparam=GadgetID(0)
Debug "Trackbar changed!"
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
TextGadget (3, 10, 40, 250, 20,"TrackBar Standard", #PB_Text_Center)
TrackBarGadget(0, 10, 60, 250, 20, 0, 10000)
ButtonGadget(1,10,10,100,20,"Click!")
SetWindowCallback(@MyWindowCallback(),0)
;SetGadgetState(0, 5000)
Repeat
ev=WaitWindowEvent()
Select ev
Case #PB_Event_Gadget
Select EventGadget()
Case 1
SetGadgetState(0, 6000)
EndSelect
EndSelect
Until ev = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.