Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem closing all forms on shutdown
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00867688
Message ID:
00867799
Views:
24
Darrell,

You can not release an object if one of it's methods is still executing. Your cmdEdit.Click() code is still on the callstack because of the modality of the called form.

In your case you should first release _screen.ActiveForm which should clear the modal form, then you can iterate the remaining forms using the _screen.Forms[] collection.

>I have a procedure that is called on shutdown. One thing it does is attempt to close all open forms. The problem I am having occurs when it tries to close a form that has opened a modal form.
>
>The code I am using to close the forms is as follows:
>
>FOR i = _screen.formCount TO 1 STEP -1
>_screen.forms[i].release
>NEXT
>
>I get the error "Cannot clear the object 'myobjectname' because it is in use. Whatever object on the form that called the modal form is the object that gives the problem.
>
>For instance, if my edit button named "cmdEdit" calls a modal form in the click method I would get the message "Cannot clear the object 'cmdEdit' because it is in use. I have even tried referencing the modal form and closing and releasing it before releasing any other forms but that does not seem to help.
>
>If I close the modal form or don't open it at all everything works fine. It seems like there is some sort of reference that the modeless form that calls the modal form is hanging onto.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform