Einzelnen Beitrag anzeigen

shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#8

AW: Frame-Name in Variable

  Alt 24. Aug 2012, 10:51
Delphi-Quellcode:
// sucht eine Komponente anhand des Pfads (z.B. 'Main.Workshop1.WorkshopDetail1')
function FindComponentByPath(owner:TComponent; name:string):TComponent;
var
   s : string;
   p : Integer;
begin
   if not Assigned(owner) then
   begin
      Result := nil;
      Exit;
   end;

   p := Pos('.', name);
   if p = 0 then
   begin
      Result := owner.FindComponent(name);
      Exit;
   end;

   s := Copy(name, 1, p-1);
   name := Copy(name, p+1, 999);

   Result := owner.FindComponent(s);
   if Assigned(Result) then
      Result := FindComponentByPath(Result, name);
end;
Andreas
  Mit Zitat antworten Zitat