pmarkov
asked on
Modal Form
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
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
Regards, Geo
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('Ran
except
// release the form
Release;
end;
end;
Regards, Geo