初始化IsDrag :=False;xx,yy :Integer;
在Form上放一Panel,拖动Panel实现工具栏的效果。
procedure TMainForm.PanelMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IsDrag :=True;
SetCapture(Handle);
XX :=x;
YY :=y;
end;
procedure TMainForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if IsDrag then
begin
Panel.Left :=x-XX;
Panel.Top :=y-YY;
end;
end;
procedure TMainForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if IsDrag then
begin
ToolPanel.Left :=x-XX;
ToolPanel.Top :=y-YY;
ReleaseCapture;
IsDrag :=False;
end;
end;