I want to create a splash screen (before the main form) that will be shown for x seconds but I don't want to delay the creation of the main form with x seconds.
So, I create the splash screen form, create the main form then after x seconds I close the splash form.
From what I understand the first form created with CreateForm is the main form. Is this right?
begin
Application.Initialize;
Application.MainFormOnTaskbar := FALSE;
Application.Title := AppName;
frmSplash:= TfrmSplash.Create(NIL); <----- not main form??
Application.CreateForm(TfrmMain, frmMain); <----- main form??
frmMain.LateInitialization;
frmMain.show;
Application.Run;
end.
Closing the splash form
The splash screen has a TTimer. The timer does some animation in the splash form and after x seconds it closes the form:
procedure TfrmSplash.CloseSplashForm;
begin
Timer.Enabled:= FALSE;
Close; <-- I do see the program reaching this point
end;
However, the application leaks mem at shutdown:
5 - 12 bytes: TMoveArrayManager<System.Classes.TComponent> x 4, Unknown x 2
13 - 20 bytes: TObservers x 1, TList x 3, Unknown x 3
21 - 36 bytes: TComponent.GetObservers$942$ActRec x 1, TPen x 2, TIconImage x 1, TPadding x 1, TBrush x 3, TTouchManager x 2, TMargins x 2, TSizeConstraints x 2, TList<System.Classes.TComponent> x 4, UnicodeString x 3, Unknown x 6
37 - 52 bytes: TDictionary<System.Integer,System.Classes.IInterfaceList> x 1, TPicture x 1, TGlassFrame x 1, TFont x 4
53 - 68 bytes: TIcon x 1
69 - 84 bytes: TControlScrollBar x 2
85 - 100 bytes: TTimer x 1
101 - 116 bytes: TControlCanvas x 2
149 - 164 bytes: Unknown x 2
437 - 484 bytes: TImage x 1
917 - 1012 bytes: TfrmSplash x 1
It looks like the frmSplash is not actually freed.