I have a project which has a main form and some other forms. When the app loads it needs to carry out some tasks and show the results in a modal form on top of the main form. T
One commonly used option is to post yourself a message in the form's OnShow
. Like this:
const
WM_SHOWMYOTHERFORM = WM_USER + 0;
type
TMyMainForm = class(TForm)
procedure FormShow(Sender: TObject);
protected
procedure WMShowMyOtherForm(var Message: TMessage); message WM_SHOWMYOTHERFORM;
end;
...
procedure TMyMainForm.FormShow(Sender: TObject);
begin
PostMessage(Handle, WM_SHOWMYOTHERFORM, 0, 0);
end;
procedure TMyMainForm.WMShowMyOtherForm(var Message: TMessage);
begin
inherited;
with TMyOtherForm.Create(nil) do begin
try
ShowModal;
finally
Free;
end;
end;
end;