Hi,
I have got panel components being created at runtime, and I cannot seem to be able to drag/drop the panels onto each other.
In the constructor I have the following code:
self.OnDragDrop:= ImageDragDrop;
self.OnDragOver:= ImageDragOver;
Then:
procedure TContainer.ImageDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if Source is TContainer then Accept := True;
end;
procedure TContainer.ImageDragDrop(Sender, Source: TObject; X, Y: Integer);
var index: integer;
begin
index:= PanelList.IndexOf(Source);
With Sender As TContainer do
begin
TContainer(Sender).Swap(index);
end;
end;
Where TContainer is a class inheriting from TPanel. I have put break points on the first line in each procedure but when I drag/drop, the execution of the code does not stop. I think this means it is a problem assigning the procedures to the events. Either that, or I am not inheriting the the usual drag drop behaviour.
I have also tried:
self.DragMode:= dmAutomatic;
self.DragKind:= dkDrag;
Please can someone help me?
James
I have got panel components being created at runtime, and I cannot seem to be able to drag/drop the panels onto each other.
In the constructor I have the following code:
self.OnDragDrop:= ImageDragDrop;
self.OnDragOver:= ImageDragOver;
Then:
procedure TContainer.ImageDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if Source is TContainer then Accept := True;
end;
procedure TContainer.ImageDragDrop(Sender, Source: TObject; X, Y: Integer);
var index: integer;
begin
index:= PanelList.IndexOf(Source);
With Sender As TContainer do
begin
TContainer(Sender).Swap(index);
end;
end;
Where TContainer is a class inheriting from TPanel. I have put break points on the first line in each procedure but when I drag/drop, the execution of the code does not stop. I think this means it is a problem assigning the procedures to the events. Either that, or I am not inheriting the the usual drag drop behaviour.
I have also tried:
self.DragMode:= dmAutomatic;
self.DragKind:= dkDrag;
Please can someone help me?
James