Title: Where does this component derive from !
Question: With RTTI from Object Pascal it''s possible to get all the parents from a class at runtime.
Answer:
function DerivesFrom(Sender:TObject; Sorted:boolean):TStrings;
var
ClassRef: TClass;
Ancestorlist:TStringlist;
SwitchList:TStringlist;
Loopint:integer;
begin
Ancestorlist:=TStringlist.Create;
ClassRef := Sender.ClassType;
while ClassRef nil do
begin
Ancestorlist.Add(ClassRef.ClassName);
ClassRef := ClassRef.ClassParent;
end;
if (not sorted) then
begin
Result:=Ancestorlist;
exit;
end
else
begin
SwitchList:=TStringlist.create;
for loopint:=Ancestorlist.Count-1 downto 0 do
Switchlist.Add(Ancestorlist.Strings[loopint]);
Ancestorlist.Free;
Result:=SwitchList;
end;
end;