Mega Code Archive

 
Categories / Delphi / Forms
 

How to show a TForm with its Classname

Title: How to show a TForm with its Classname uses MyFormOne, MyFormTwo; procedure ShowOneOfMyForm(FormClassName: string); begin with TFormClass(FindClass(FormClassName)).Create(Application) do try ShowModal; finally Free; end; end; { Geben Sie z.B. "TMyFormTwo" in dem TEdit und clicken Sie auf dem Knopf } { How to use it? Give "TMyFormTwo" in a TEdit and click the TButton...} procedure TForm1.btShowMyFormClick(Sender: TObject); begin //at runtime ShowOneOfMyForm(InputEdit.Text); // or directly in your code ShowOneOfMyForm('TMyFormOneF'); end; initialization RegisterClasses([TMyFormOneF, TMyFormTwoF]); end.