I need to centralize the MDI Child Forms creation into a unique procedure in Delphi (VCL). The idea is to do some actions every time an MDI Child Form is created no matter its type, i.e., to add its caption name into a List to get access to that MDI child form. Like this:
procedure TMainForm<T>.CreateMDIChild(const ACaption : String);
var
Child: T;
begin
{ create a new MDI child window }
Child := T.Create(Application);
Child.Caption := ACaption;
// add this child to the list of active MDI windows
...
end;
procedure TMainForm.Button1Click(Sender : TObject);
begin
CreateMDIChild<TMdiChild1>('Child type 1');
CreateMDIChild<TMdiChild2>('Child type 2');
...
But, I don't have experience with generics. Any help I'll appreciate it. Thank you so much.