DelphiFAQ Home Search:
General :: Programming :: Delphi :: VCL
About the Delphi VCL (Visual Component Library)

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Create a form knowing the class name only

If you run into a situation, where you would like to create and show a form, but you know the class's name only, you need to use the functions FindClass:

  procedure ShowAnyForm(sFormClassName: string);
   var
     FormClassType: TFormClass;
     Form: TForm;
   begin
     // possibility #1    FormClassType := TFormClass(FindClass(sFormClassName));
     Application.CreateForm(FormClassType, Form);
     Form.ShowModal;
     Form.Free;
 
     // possibility #2    Form := TForm(TComponentClass(FindClass(sFormClassName)).Create(Self));
     Form.ShowModal;
     Form.Free;
   end;
 

Generated 20:01:27 on Jan 21, 2018