Solved

Modal Form

Posted on 2002-07-17
4
221 Views
Last Modified: 2010-04-04
Hello

I want to create and display a form as the ModalForm.

with TMyMoladForm.Create(Self) do begin
  ...
  ...
end;

I want to set-up some parameters in the TMyModalForm.FormCreate procedure and then I want to show the form.

But how can I to Show an error message and CLOSE or DO NOT SHOW the modal form if exception appears during TMyModalForm.FormCreate procedure executing?

Thanks
0
Comment
Question by:pmarkov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 7161633
Hi,

Try this one:

procedure TForm2.FormCreate(Sender: TObject);
begin
  try
    // evaluate the conditions here
    // I've hardcoded an exception to be raised so this form will never come up
    raise ERangeError.CreateFmt('Range error', []);
  except
    // release the form
    Release;
  end;
end;

Regards, Geo
0
 

Accepted Solution

by:
Chalo earned 50 total points
ID: 7163992
Hi,

Try this

procedure TMainForm.Button1Click(Sender: TObject);
begin
  With TFormToDisplay.Create(nil) Do
    Try
      ShowModal;
    Finally
      Release;
  End
end;


Best regards Chalo
0
 

Author Comment

by:pmarkov
ID: 7164046
Thanks!
0
 
LVL 17

Expert Comment

by:geobul
ID: 7164207
The code from the accepted answer doesn't hide or close the second form if an exception occurs in its OnCreate event. The second form is always displayed. What kind of solution is this?

Regards, Geo
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question