把Label的DragMode设为dmAutomatic,DragKind设为dkDrag,Form的DockSite设为True,<br>Form的OnDragOver事件可这么写:<br><br>procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;<br> State: TDragState; var Accept: Boolean);<br>begin<br> ......<br> with Label1 do<br> begin<br> Parent:=Form1;<br> Left:=x;<br> Top:=y;<br> end;<br> Accept:=True;<br> ......<br>end;(鼠标形状不好看,自己解决吧)<br><br><br>另一个办法:<br>procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);<br>begin<br> Label1.Tag:=1;<br>end;<br><br>procedure TForm1.Label1MouseUp(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br>begin<br> Label1.Tag:=0;<br>end;<br><br>procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);<br>Var<br> P:TPoint;<br>begin<br> with Label1 do<br> if Tag=1 then<br> begin<br> P.x:=X;<br> P.y:=Y;<br> Left:=Form1.ScreenToClienT(ClientToScreen(P)).X;<br> Top:=Form1.ScreenToClienT(ClientToScreen(P)).Y;<br> end;<br>end;<br><br>