Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't my modal form close?

Status
Not open for further replies.

jjschwartz

Technical User
Feb 3, 2004
23
US
I've abstracted this problem to, hopefully, simplify it without losing the key elements.

I have a project with 3 forms that are auto-created: Form1 (the main form), Form2 and Form3.

Form1 has a button whose handler is:

Form2.showmodal;

Form2 has a button whose handler is:

Form2.close;
Form3.showmodal;

When I push Form1's button, Form2 shows (good).
When I push Form2's button, Form3 shows but Form2 stays open (bad). When I close Form3, then Form2 closes.

Can someone help explain this behavior? I'm obviously trying to jump between all my forms.

TIA,
Jeff Schwartz

 
Jeff,

why don't you try to inverse your code :

Form3.showmodal;
Form2.close;

cheers,

John
 
well I the function ShowModal never returns until the
Dialog that it shows had closes.

If you use showmodal the Form should Close it with

ModalResult := mrOK;

instead

Form2.close


"ModalResult := mrOK;" close the Modal Dialog and Return the Integer (here mrOK, but any othr integer-vallue is posible) to the Calling "showmodal"-Function.
now you can call Form3 from the Form1 if that Button was pressed.

var Result2, Result3 : integer;

[...]

Result2 := Form2.showmodal;
if Result=mrOK then Result3 := Form3.showmodal;


I hop that helps a little ...
Leonardo
 
Yes it will have something to do with Form2 opening Form3. While form3 is open form2 will not close. if leonardo code doesn't help then close form2 but make it trigger form3.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top