Author: Jonas Bilinkevicius How to dynamically retrieve class information Answer: This will create an instance of the class specified in the GetClass call: 1 procedure TForm1.FormCreate(Sender: TObject); 2 begin 3 {This only works for classes registered using RegisterClass} 4 RegisterClasses([TButton, TForm]); 5 end; 6 7 procedure TForm1.Button1Click(Sender: TObject); 8 var 9 CRef: TPersistentClass; 10 PTI: PTypeInfo; 11 AControl: TControl; 12 begin 13 CRef := GetClass('TButton'); 14 if CRef <> nil then 15 begin 16 AControl := TControl(TControlClass(CRef).Create(Self)); 17 with AControl do 18 begin 19 Parent := Self; 20 Width := 50; 21 Height := 30; 22 end; 23 Inc(Id); 24 end 25 else 26 MessageDlg('No such class', mtWarning, [mbOk], 0); 27 end;