I created a Custom scrollbox derives from TScrollbox that works the same except that it will scrolls when dragging in the client area aside from its scrollbars.
My problem now is i cannot Drag To Scroll when mouse is on a button or panel inside my CustomScrollbox.
the MouseDown, MouseUp, MouseMove override will not trigger because it hovers into different controls.
How can I keep tracking the MouseDown, MouseUp, MouseMove and prevent Button/Panels events from firing(inside my CustomScrollbox) when i start dragging?
here's the video of my smooth CustomScrollbox
So you want to adjust the mouse down behaviour of all childs, in such way that when a dragging operation is being initiated, the mouse events of the clicked child should be ignored. But when no drag is performed, then it would be required to fire the child's mouse events as usual.
Not a bad question actually. Since most of the default control interaction is tight to the release of the mouse button (e.g.
OnClick
is handled inWM_LBUTTONUP
), this still should be possible in an intuitive manner.I tried the code below, and it feels quite nice indeed. It involves:
WM_PARENTNOTIFY
to catch when a child control is clicked on,Child.OnMouseMove
andChild.OnMouseUp
,Mouse.DragThreshold
,Note: When no drag is initiated (mouse movement <
Mouse.DragThreshold
), all mouse and click events of the clicked child remain intact. Otherwise onlyChild.OnMouseDown
will fire!For testing purposes, this answer is incorporated in the code above.
With thanks to @TLama for suggesting to use
WM_PARENTNOTIFY
.