procedure TForm1.EnterShape(Sender: TObject);
const
Current: TShape = nil;
var
i: Integer;
begin
if Sender.InheritsFrom(TShape) then begin
{ Do whatever you want for the "active" shape }
Memo1.Lines.Add('Shape: %s', [TComponent(Sender).Name]);
{ And now process the rest of them }
if not Assigned(Current) then begin
{ Keep track of which Shape called first}
Current := TShape(Sender);
{ Find all shapes and EnterShape() for each EXCEPT the Current one }
for i := 0 to ComponentCount-1 do
if Components[i].InheritsFrom(TShape) { Is it a shape ... }
and (Components[i] <> Current) then { and not the "top"? }
EnterShape(Components[i]);
{ All done? Back to defaults }
Current := Nil;
{ This just to make the log look nicer ;) }
Memo1.Lines.Add('----------');
end;
end;
end;