Thema: Delphi klasseninstanz finden

Einzelnen Beitrag anzeigen

Hawkeye219

Registriert seit: 18. Feb 2006
Ort: Stolberg
2.227 Beiträge
 
Delphi 2010 Professional
 
#4

Re: klasseninstanz finden

  Alt 4. Jun 2006, 12:40
Hallo Frank,

ohne Garantie:

Delphi-Quellcode:
function getSubInstance (aRoot: TComponent; const aName: string): TObject;
  var ii : Integer;
      SL : TStrings;
begin
  SL := TStringList.Create;
  SL.Delimiter := '.';
  SL.DelimitedText := aName;
  if (SL.Count = 0) then
    Result := nil
  else
    begin
      Result := aRoot.FindComponent(SL[0]);
      ii := 1;
      while (Assigned(Result) and (ii < SL.Count)) do
        if (GetPropInfo(Result, SL[ii], [tkClass]) = nil) then
          Result := nil
        else
          begin
            Result := GetObjectProp(Result, SL[ii]);
            Inc (ii);
          end;
    end;
  SL.Free;
end;
Gruß Hawkeye
  Mit Zitat antworten Zitat