ControlDragging was: Re: [lazarus] CVS Changes

Marc Weustink weus at quicknet.nl
Thu Jun 15 16:08:58 EDT 2000


At 21:24 15-06-2000 +0200, Alexander Reiter wrote:
>i think the problem is in TDesignerForm.MouseMove.
>if you try this, you can move your control. well is not the
>best solution, but it is a good starting point. take a look
>at this:
>
>  Procedure TDesignerForm.MouseMove(Sender: TObject; Shift: TShiftState;
>X, Y: Integer);
>var
>   dx, dy: Integer;
>begin
>   //if TCOntrol(sender).dragging then
>   if (FMoveCOntrol.Control = Sender)
>   then begin
>     WriteLn(Format('[TDesignerForm.MouseMove] Start(%d, %d) Stop(%d,
>%d)', [FMoveCOntrol.X, FMoveCOntrol.Y, X, Y]));
>   not correct  --> //dx := X - FMoveCOntrol.X;
>   not correct  --> //dy := Y - FMoveCOntrol.Y;
>      dx := X - FMoveControl.Control.Left;
>      dy := Y - FMoveControl.Control.Top;
>     FMoveControl.Control.Left := FMoveControl.Control.Left + dX;
>     FMoveControl.Control.Top  := FMoveControl.Control.Top + dY;
>   end;
>end;

Don't think so.
X and Y are the coordinates of the mousepointer within the control at the 
moment of the mousedown/move event, so you must calc the relave 
displacement from these points and not from the left and top. Otherwise you 
are comapring two different things.

Marc







More information about the Lazarus mailing list