Solved

Modal Form

Posted on 2002-07-17
4
215 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

15 Experts available now in Live!

Get 1:1 Help Now