Solved

Modal Form

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

Industry Leaders: 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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