在MouseDown的时候记下来鼠标的位置,然后在MouseMove的时候设置其Left和Top就可以了
OnMouseDown
begin
  GetCursorPos(FPoint);//需要在Form的Private出声明该变量 FPoint: TPoint;
  FMouseDowned := True;//需要在Form的Private出声明该变量 FMouseDowned: Boolean;
end;
OnMouseMove
var
  P: TPoint;
begin
  if FMouseDowned then
  begin
    GetCursorPos(P);
    Label1.Top := Label1.Top + P.Y - FPoint.Y;
    Label1.Left := Label1.Left + P.X - FPoint.X;
    FPoint := P;
  end;
end;
ONMOuseUp
begin
  FMouseDown := False;
end;

解决方案 »

  1.   

    procedure TFormMain.PanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
    if Button = mbLeft then
    begin
    ReleaseCapture;
    PanelShowTime.Perform(WM_SysCommand, c_nDragMove, 0);
       end;
    end;
      

  2.   

    楼上,c_nDragMove这个是什么参数?
      

  3.   

    OnMouseDown
      cursor:=crDrag;OnMouseMove
     
      if cursor=crDrag then
        移动控件;OnMouseUp
      cursor:=crDefault
      

  4.   

    procedure TFormMain.PanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
      if Button = mbLeft then begin
        ReleaseCapture;
        TWinControl(Sender).Perform(WM_SysCommand, SC_MOVE + 1, 0);
      end;
    end;
      

  5.   

    //look:
    http://www.csdn.net/expert/topic/360/360881.shtm
      

  6.   

    procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    const SC_DragMove=$F012;
    begin
    ReleaseCapture;
    (Sender as TWinControl).Perform(WM_SysCommand,SC_DragMove,0);
    end;
    其中的EDIT1是控件名,作相应的改动!
      

  7.   

    以上方法仅适用于窗口控件。TLabel是非窗口控件,所以不能用此方法。
      

  8.   

    而且,如果在Windows设置中,若没有设置“拖动时显示窗口内容”,则拖动时只能显示一个虚线框。
      

  9.   

    OnMouseDown
      cursor:=crDrag;OnMouseMove  if cursor=crDrag then
        移动控件;OnMouseUp
      cursor:=crDefault 
      

  10.   

    OnMouseDown
      cursor:=crDrag;OnMouseMove  if cursor=crDrag then
        移动控件;OnMouseUp
      cursor:=crDefault 
      

  11.   

    我来补充一下:
    const
    //---系统常量---
    c_nDragMove = $F017;                //移动控件消息procedure TFormMain.PanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
    if Button = mbLeft then
    begin
    ReleaseCapture;
    PanelShowTime.Perform(WM_SysCommand, c_nDragMove, 0);
      end;
    end;