I tried using the 'gadget event hack' to send the event as a change event type but all it did was queue the events and fire them all at once when the mouse button was released (much to my annoyance, I should have known better, I went through all this when I was dismayed at why the windowevent blocks on window movement). I also tried to disable the arrows based on position, but they just get re-enabled (again, much to my annoyance).
I wrote this mainly because I wanted a solution that didn't require setting a callback for the whole window, but I guess if you have a callback anyway, it wouldn't matter.
Functions use window props, so no need to keep a track of default window callbacks, etc.
Code: Select all
Procedure ScrollProc(SbarID,Msg,wParam,*lParam.SCROLLINFO)
With *lParam
Protected result,*defproc=GetProp_(SbarID,@"scrollbar_winproc")
If *defproc
result=CallWindowProc_(*defproc,SbarID,Msg,wParam,*lParam)
EndIf
If Msg=#SBM_SETSCROLLINFO And *lParam
If Not \nPos=GetProp_(SbarID,@"scrollbar_value")
SetProp_(SbarID,@"scrollbar_value",\nPos)
Debug \nPos
EndIf
EndIf
ProcedureReturn result
EndWith
EndProcedure
Procedure SmoothScrollBarGadget(Gadget,x,y,Width,Height,Min,Max,PageLength,flags=0)
Protected hwnd,gid=ScrollBarGadget(Gadget,x,y,Width,Height,Min,Max,PageLength,flags)
hwnd=gid
If Gadget=#PB_Any
hwnd=GadgetID(gid)
EndIf
SetProp_(hwnd,@"scrollbar_winproc",SetWindowLongPtr_(hwnd,#GWLP_WNDPROC,@ScrollProc()))
SetProp_(hwnd,@"scrollbar_value",Min)
ProcedureReturn gid
EndProcedure
Where you see 'Debug \nPos', this is where you do your thing! Works perfect on Win7. Enjoy!
EDIT: Forgot to return the gadget number, fixed.