Re: ScrollBar events only on release
Posted: Wed Dec 21, 2011 7:01 pm
Try this :
Here, the sublass proc calls the previous handler (the one installed by PB) to handle, in particular, the scrolling events. PB's handler will use SetScrollInfo_() to actually move the scrollthumb etc. and our procedure simply retrieves this new value via GetGadgetState(). Comment out the result = ... line and you will see that no movement of the scrollthumb takes place (tracking aside) which is the default behaviour for Windows.
Code: Select all
Global gOldProc
Procedure WndProc(WindowID, Msg.i, wParam.i, lParam.i)
result = CallWindowProc_(gOldProc, WindowID, Msg, wParam, lParam)
Select Msg
Case #WM_HSCROLL
scrollCode = wParam & $ffff
If scrollCode <> #SB_THUMBPOSITION And scrollCode <> #SB_ENDSCROLL
Debug GetGadgetState(0)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
W = 512
H = 384
OpenWindow(0, 0, 0, W, H, "", #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
ScrollBarGadget(0, 10, 10, 200, 17, 0, 5, 1)
gOldProc = SetWindowLongPtr_(WindowID(0), #GWLP_WNDPROC, @WndProc())
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
CloseWindow(0)
Break
EndSelect
ForEver