Delphi .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Create a form knowing the class name only
This article has not been rated yet. After reading, feel free to leave comments and rate it.
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
FormClassType := TFormClass(FindClass(sFormClassName));
Application.CreateForm(FormClassType, Form);
Form.ShowModal;
Form.Free;
Form := TForm(TComponentClass(FindClass(sFormClassName)).Create(Self));
Form.ShowModal;
Form.Free;
end;
| |  | |  |
Comments:
|