We have Delphi XE MDI project. We need to open a Dialog form (form with with bsDialog property) at the startup of the application just after the MDI main form has been created and showed.
DELPHI XE - how show a dialog form at mdi application startup?
821 Views Asked by Avrob At
2
There are 2 best solutions below
0

You can add something to your form's OnShow
event, but the dialog will show before the main form is actually visible. So, you need to delay the showing of the dialog until the main form is actually visible.
I'm sure there are other ways to do this, but I add a handler to TApplication.OnIdle
, and show the dialog there. Obviously you'd need to use a boolean flag in the main form to make sure that the dialog was only ever shown once. And it's generally cleaner to use TApplicationEvents
to work around Delphi's lack of multi-cast events.
procedure TMainForm.ApplicationIdle(Sender: TObject; var Done: Boolean);
begin
if not FStartupCalled then begin
FStartupCalled := True;//FStartupCalled is a member field of TMainForm
DoApplicationStartup;//this would show your dialog
end;
end;
You can do this