Page 1 of 1
Event for scrolling of ScrollAreaGadget?
Posted: Sun Nov 08, 2009 3:38 am
by mesozorn
What would be the best way to capture an event WHILE the user is scrolling the scrollbars of a ScrollAreaGadget? #WM_ACTIVATE only works when the user initially clicks the scrollbar and then later lets go, and #WM_MOUSEMOVE also stops reporting while the user is moving a scrollbar.
I need to be able to track the #PB_ScollArea_X and #PB_ScrollArea_Y while it is being moved by the user, rather than just after the user has let go of the mouse button and chosen a final landing position.
Is there an easy way to do this? Thanks...
Re: Event for scrolling of ScrollAreaGadget?
Posted: Sun Nov 08, 2009 11:06 am
by srod
#WM_HSCROLL, #WM_VSCROLL and #WM_MOUSEWHEEL are probably what you are after. You'll need to subclass the scrollarea first though.
Re: Event for scrolling of ScrollAreaGadget?
Posted: Sun Nov 08, 2009 11:24 pm
by mesozorn
srod wrote:#WM_HSCROLL, #WM_VSCROLL and #WM_MOUSEWHEEL are probably what you are after. You'll need to subclass the scrollarea first though.
Thanks.. So far I haven't had any luck getting the #WM_VSCROLL/#WM_HSCROLL messages to show up, but my knowledge of the API is admittedly very limited. Is there an example that you know of anywhere that might provide further guidance?
Re: Event for scrolling of ScrollAreaGadget?
Posted: Sun Nov 08, 2009 11:54 pm
by Arctic Fox
Try this
Code: Select all
Global OldSubclass
Procedure ScrollCallback(Handle, Message, wParam, lParam)
Select Message
Case #WM_HSCROLL
Debug "#WM_HSCROLL"
Case #WM_VSCROLL
Debug "#WM_VSCROLL"
EndSelect
ProcedureReturn CallWindowProc_(OldSubclass, Handle, Message, wParam, lParam)
EndProcedure
OpenWindow(0, 100, 100, 300, 300, "")
ScrollAreaGadget(0, 5, 5, 290, 290, 500, 500, 30)
StringGadget(1, 5, 5, 100, 20, "Gadget 1")
StringGadget(2, 305, 405, 100, 20, "Gadget 2")
CloseGadgetList()
OldSubclass = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @ScrollCallback())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Re: Event for scrolling of ScrollAreaGadget?
Posted: Tue Nov 10, 2009 7:19 pm
by mesozorn
Thanks Arctic Fox, that's great and much appreciated. I am learning the API a little at a time, but callbacks and subclassing are still mostly foreign to me so I wouldn't likely have stumbled onto the right syntax without assistance.
Re: Event for scrolling of ScrollAreaGadget?
Posted: Tue Nov 10, 2009 7:40 pm
by Arctic Fox
You are welcome
When you are ready to learn more about subclassing, you should definitely have a look at
srod's tutorial (see the
nxSoftware website.)
Re: Event for scrolling of ScrollAreaGadget?
Posted: Tue Nov 10, 2009 8:34 pm
by mesozorn
Arctic Fox wrote:You are welcome
When you are ready to learn more about subclassing, you should definitely have a look at
srod's tutorial (see the
nxSoftware website.)
Wow, I just read through the entire thing and it was both extremely helpful and excellently written. Thanks for the direction to it and thanks srod for writing it in the first place. Though the API in general is still somewhat of a big daunting dragon to me, I now feel that I am at least equipped with a nice shiny new dagger with which to do battle, as opposed to the wooden toothpick I was brandishing before. Perhaps someday I'll wield a powerful broadsword like srod does but I wouldn't count on it anytime soon!
