Thema: Delphi klasseninstanz finden

Einzelnen Beitrag anzeigen

Hawkeye219

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

Re: klasseninstanz finden

  Alt 5. Jun 2006, 13:44
Hallo Frank,

ich konnte den Code nur mit Delphi 6 testen. Vielleicht funktioniert diese Anpassung an Delphi 3:

Delphi-Quellcode:
function getSubInstance (aRoot: TComponent; const aName: string): TObject;
  var ii : Integer;
      SL : TStrings;
      Info : PPropInfo;
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
        begin
          Info := GetPropInfo(Result, SL[ii]);
          if ((Info = nil) or (Info.PropType^.Kind <> tkClass)) then
            Result := nil
          else
            begin
              Result := TObject(GetOrdProp(Result, Info));
              Inc (ii);
            end;
        end;
    end;
  SL.Free;
end;
Gruß Hawkeye
  Mit Zitat antworten Zitat