egroups 2 Posted January 19, 2023 Is anyway how can get list all classes in project,inherited from specific class and have specific property? By refactoring I can clear properties in descendant,which is defined in parent class. Share this post Link to post
Brian Evans 108 Posted January 19, 2023 MMX Code explorer (now free and maintained by Uwe Raabe) has a class browser that might be useful within a file. MMX – speed up your Delphi development (mmx-delphi.de) 1 Share this post Link to post
programmerdelphi2k 237 Posted January 19, 2023 (edited) maybe my sample can help you to start... implementation {$R *.dfm} uses System.Rtti, Unit2; procedure TForm1.Button1Click(Sender: TObject); var LCtx : TRttiContext; LType : TRttiType; LProp : TRttiProperty; LPropParent: string; begin LCtx := TRttiContext.Create; for LType in LCtx.GetTypes do begin if (LType.TypeKind = tkClass) { TRttiInstanceType } and { } (LType.IsInstance) and { } (LType.AsInstance.MetaclassType.InheritsFrom(TMyClassXXXX { myClass } ) or { } LType.AsInstance.MetaclassType.InheritsFrom(TForm { myClass } )) then begin Memo1.Lines.Add(slinebreak + { } LType.Name + ', ' + { } LType.AsInstance.MetaclassType.UnitName + ', ' + { } LType.AsInstance.MetaclassType.UnitScope); // for LProp in LType.GetProperties do if (LProp.Name = 'Width' { myPropetyName } ) then begin LPropParent := 'Parent=nil'; // if (LProp.Parent <> nil) then LPropParent := 'Parent=' + LProp.Parent.ToString; // Memo1.Lines.Add('..... property: ' + LProp.Name + ', ' + LPropParent); end; end; end; end; Edited January 19, 2023 by programmerdelphi2k 1 Share this post Link to post