Greetings Dear Delphians,
Say we have 20 Forms in an App. We use these 6 lines to create 20 Forms at different places.
Form1 := TForm1.Create;
try
Form1.ShowModal;
finally
Form1.Free;
end;
When refactoring we can see this is a lot of code duplication and we should encapsulate form creation in a procedure like this.
procedure ShowForm ( ThisForm: TCustomForm ) ;
begin
ThisForm := TCustomForm(ThisFormClass.Create);//?? How to Get Form Class
try
ThisForm.ShowModal;
finally
ThisForm.Free;
end;
end;
I only have problem in first line. how to get ThisForm parent class to call it.
Is it even possible?
If yes then how?
What about FMX?
Any help or pointer is appreciated.
Thanks and stay blessed