How to use SetCapture without breaking TPaintbox event handling
Posted on 2006-06-20
This is a tricky one, so points are awarded accordingly. Please note I need a solution to THIS problem not an alternative approach.
I have a TPaintBox aligned as alClient accross a standard windows form. I needed to track a users rubber band selection outside of the application window (which calls code to scroll the contents up, down etc).
I can't just use MouseMove to detect when the cursor has reached the end of the client area, because not all mousemove events are trapped by Delphi
So I call
SetCapture( MypaintBox.Parent.Handle );
in FormMouseDown in order to grab all MouseMove events
and then in FormMouseUp I call ReleaseCapture.
The problem is that after this, all MouseMove messages continue to come unmodifed from the parentform rather than adjusted to the Client area of the TPaintBox as before the call to SetCapture.
Is there any way to reset the previous behavior?