Solved

Modal Form

Posted on 2002-07-17
4
217 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now