Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag Drop in Delphi

Status
Not open for further replies.

siu01jam

Programmer
Oct 2, 2003
12
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top