with Tpanel.create(application) do
..
OnDragOver := F_Main.MyDragOver;
OnDragDrop := F_Main.MyDragDrop;
OnMouseDown := F_Mian.MyMouseDown;
..
........
..................
procedure TF_Main.MyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft)and ( ssCtrl in Shift ) then
begin
TheSpot.X:=X;
TheSpot.Y:=Y;
if (Sender is TPanel) then TPanel(Sender).BeginDrag(true);
end;
end;
......
.......
procedure TF_Main.MyDragDrop(Sender, Source: TObject; X, Y: Integer);
var
l,t:integer;
begin
if (Source is TPanel) then
begin
//on itself?
if Sender is TPanel then
begin
TPanel(Source).Left := TPanel(Source).Left + x - TheSpot.X;
TPanel(Source).Top := TPanel(Source).Top + y - TheSpot.Y;
end
else
//or, somewhere inside ScrollBox!
begin
TPanel(Source).Left := X - TheSpot.X;
TPanel(Source).Top := Y - TheSpot.Y;
end;
end;
//*****************************
end;
....
...
.....
procedure TF_Main.MyDragOver (Sender, Source: TObject; X,
Y: Integer; State: TDragState;var Accept: Boolean);
begin
MyDragDrop(Sender,Source,x,y);
end;
......
.....