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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing modeless form

Status
Not open for further replies.

JGAS67

Programmer
Oct 21, 2007
5
SI
Hi,

i'm having problems closing modeless form. I have a form A, that is modal and my subform B, that is modal too, but because i need to open further windows (C) programatically, i set it as windowtype = 0 (in order to be able to open child forms (C) from this form (B)) in its init event. According to what i want to achieve, i open further forms C (modal) and when i want to close form C, i want to close my modeless form (B) too, so i can return to my mainform (A) without user intervention needed. I have a command button on my modeless form (B) that releases the form, so i do a thisform.commandx.click in order to close the form (B), but the form (B) is not closed and it remains inactive, while my main form (A) receives focus. In order to close the form B, i need to close form A and only then i can close the form B. GetWindow and DestroyWindow isn't working so i'm obviously missing something.

Any help would be appreciated!

Andrej
 
>.In order to close the form B, i need to close form A and only then i can close the form B

Sounds as if Form A is holding a reference to Form B. If that is the case, then you need to release the reference in Form A before you can release Form B.

----
Andy Kramek
Visual FoxPro MVP
 
Andy, this certainly sounds reasonable. How should i check, if this (holding a reference) is the case with my situation? If what you've said applies to my case, how can i release the reference? Sorry for asking potentially stupid question, but one learns only by asking.

Regards,
Andrej
 
I've checked for the reference to the "to be closed" form after returning from it and, yes, i still have a reference to it. I've tried the RELEASE MyFormName to get rid of the reference, but the form still remains active (hidden behind the father form, that initiated the child form). Should i do anything else, besides releasing the object?

Regards,
Andrej
 
Andrej,

Where are you holding the reference to form B? Do you have a property of Form A that contains an object reference?

That would be the case, for example, if Form A did something like:
THISFORM.Something = CREATEOBJECT("form")
or:
DO FORM FormB NAME Thisform.Something

It's the "something" in the above examples that would hold the object reference, and which you would need to release.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

opening is done via

do form MyFormName with [parameters, ...]

and after returning from the form i use

if type("MyFormName") = "O" and !isnull(MyFormName)
RELEASE MyFormName
endif

According to your suggestion, there's no reference, but form remains visible (although in background).

In MyFormName i use ThisForm.Release to "release" the form.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top