Hola de nuevo CarlosAlberto, puedes utilizar también el parámetro source de los eventos OnDragDrop y OnDragOver, te pongo un ejemplo.
Digamos que quieres crear varios TLabel y no solo uno y asignarles el evento Onclick a todos, en cual solo vamos a mostrar su Caption de cada Label.
Código Delphi
[-]
public
I : Integer;
Lab:TLabel;
procedure LabClick(Sender: TObject);
....................................................
....................................................
procedure TForm1.LabClick(Sender: TObject);
begin
Showmessage(TLabel(Sender).Caption);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Lab:=TLabel.Create(self);
With Lab do
begin
Parent:=self;
Caption:='Label'+IntToStr(I);
Name := '';
DragMode := dmAutomatic;
Left:=10;
Top:=I;
OnClick := LabClick; Inc(I,20);
end;
end;
Y en los eventos OnDragDrop y OnDragOver del Panel lo siguiente.
Código Delphi
[-]
procedure TForm1.Panel1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (Source is TLabel) then
begin
TLabel(Source).Parent := Panel1;
TLabel(Source).Left := X;
TLabel(Source).Top := Y;
end;
end;
procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := (Source is TLabel);
end;
Si tienes duda sobre algo, solo pregunta y no te olvides inicializar I en en Oncreate de tu formulario.
Saluditos