Ide Indy Delphi

Title: How to move components at Runtime
type
TForm1 = class(TForm)
Image1: TImage;
procedure ControlMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ControlMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure ControlMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
FDownX,
FDownY: Integer;
FDragging: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
type
TMoveCracker = class(TControl);
procedure TForm1.ControlMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FDownX := X;
FDownY := Y;
FDragging := True;
TMoveCracker(Sender).MouseCapture := True;
end;
procedure TForm1.ControlMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if FDragging then
with Sender as TControl do
begin
Left := X - FDownX + Left;
Top := Y - FDownY + Top;
end;
end;
procedure TForm1.ControlMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if FDragging then
begin
FDragging := False;
TMoveCracker(Sender).MouseCapture := False;
end;
end;