Articles

First of all, you must set DragMode property of ToolBar to dmAutomatic and then use code below. RasX parameter is distance from ToolBar1.Left to X coordinate of mouse. RasY parameter is distance from ToolBar1.Top to Y coordinate of mouse.

var
  Form1: TForm1;
  RasX, RasY: Integer;

implementation

procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  with Source as TToolBar do
  begin
    Top:=Y-RasY;
    Left:=X-RasX;
  end;
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept:=Source=ToolBar1;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  RasX:=X-ToolBar1.Left;
  RasY:=Y-ToolBar1.Top;
end;