用一Panel作工具栏,可以如下 :
在Form上放一Panel
var
xx,yy :Integer;
IsDrag :Boolean;
procedure TMainForm.FormCreate(Sender: TObject);
begin
IsDrag :=False;
end;
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
Panel.Left :=x-XX;
Panel.Top :=y-YY;
ReleaseCapture;
IsDrag :=False;
end;
end;