在运行时能用鼠标拖动报表上的LABEL
在运行时能用鼠标拖动报表上的LABEL hlms Delphi 笔记 - delphi2007.net
http://www.delphi2007.net/delphiblog/html/delphi_2004992226395018.html
private { Private declarations } OriginalPos,DownPos,CurrentPos:TPoint; mousedown:boolean;//在CRETE中将它初始化为false procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin OriginalPos.x:=Label1.Left; OriginalPos.y:=Label1.Top; DownPos.x:=X; DownPos.y:=Y; DownPos:=ClientToScreen(DownPos); if Button = mbLeft then MouseDown:=True; end; procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if MouseDown then begin CurrentPos.x:=X; CurrentPos.y:=Y; CurrentPos:=ClientToScreen(CurrentPos); Label1.Left:=OriginalPos.X+CurrentPos.X-DownPos.X; Label1.Top :=OriginalPos.Y+CurrentPos.Y-DownPos.Y; end; end; procedure TForm1.Label1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin mousedown:=false; end;