Solved

Modal Form

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

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

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 45
error 1.1 400 Bad request idhttp delphi 18 199
How to renew a Delphi rad-studio licence? 5 75
control image tags in a string ? 12 153
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…

685 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