在创建的时候把
DragMode 属性设置成 dmAutomatic
//假设Form1是接受对象,DragMode 属性也设置成 dmAutomatic
procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=True;
end;
procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
TControl(Source).Left:=X;
TControl(Source).Top:=Y;
end;