2

Hi all,

I want to display that option form above the Main Form when application will run. So How can I display Option form with Main form in background at start?

Thanks for help.

2
  • its like pop up form with Main Form should display in background. Commented Aug 2, 2011 at 11:55
  • I tried create the option form on OnCreate or Onshow events of Main form but it displays only option form. :( Commented Aug 2, 2011 at 11:58

2 Answers 2

2

Can use OnActivate. Have to wrap it in some code to prevent it from firing when other application forms close and the main one gets activated again however.

procedure TForm1.FormActivate(Sender: TObject);
Const
{$J+}
  SettingsShown : Boolean = false;
{$J-}
begin
  if SettingsShown = false then
  begin
    Form2.ShowModal;
    SettingsShown := True;
  end;
end; 
Sign up to request clarification or add additional context in comments.

1 Comment

I think a non-modal form would be better for any automatically-popped-up-forms, and if you are going to use modal forms, be sure that you will enventually suffer from the dreaded Z-Order bug unless you have a version of Delphi that has the fix (and you use the fix, set the window's PopupParent), or you write some special code to work around it.
0

instead of using OptionForm.ShowModal in OnCreate or OnShow create a custom message like Const AM_ShowOptionForm = WM_APP +1 and Post a message back to your main form.

Add a message handler on your main form such as

Procedure RecieveOptionFormMessage(var Msg:TMessage); Message AM_ShowOptionForm
begin
    OptionForm.ShowModal;
end;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.