ControlDragging was: Re: [lazarus] CVS Changes

Robert Scott Horning roberth at
Wed Jun 14 17:09:46 EDT 2000

Marc Weustink wrote:

> Mouse.Cursorpos is given in screen coordinates, not in form coordinates.
> Onmousedown you store Cursorpos (or better, the given X and Y),
> onmouseUp you calc the difference with the new Cursorpos (or better, the
> given X and Y) THe difference is added to the Left and Top.
> I committed a solution which normally should work, however it doesn't due
> to a bug in the MouseMove and MouseUp handlers
> MouseMove / MouseUp should always give the mouseposition X and Y in the
> Sender coordinates.  It does as long as the up event occoured in the
> control itself. However if you are outside the control you get the X and Y
> in Form coordinates.
> Marc

Having done quite a bit of Windows programming, especially with the Mouse
Move/Mouse Up events, this is not correct.  The coordinates should ALWAYS be in
relation to Sender (even if the X & Y are negative... which is possible even for
Form or even Screen coordinates.)  The problem comes when you try to move
something, and as soon as you cross a threshold (like the edge of a control) it
jumps suddenly to a totally different location on the monitor.  Having made
mistakes like this in some of my GUI programming has caused hours of grief when
I got the coordinate systems mixed up.

Robert Scott Horning
Trans-Lux West
1651 North 1000 West
Logan, Utah  84321
Phone: (435) 716-8696
FAX: (435) 752-8513
E-mail:  roberth at

More information about the Lazarus mailing list