Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
This can't be impossible to do
Message
De
31/03/2002 19:50:51
 
 
À
30/03/2002 14:07:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00639169
Message ID:
00639312
Vues:
16
Hi Gregory

Thanks for your reply.

I think have figured out where I was making a mistake in my on shutdown procedure. I created a test app that I dropped different on shutdown procedures into and it will log the on shutdown execution sequence to a file. I got some pretty interesting and varying results from some of the code I tried. I have learned many things about how VFP behaves on shutdown with this exercize.

1. Not all forms can be released in the on shutdown procedure. When a modal form is called from a modeless form with a button click, the button click is in the procedure stack and the calling form cannot be unloaded or cleared until after on shutdown procedure has completed its processing or quit is issued. That is why I was getting Error 1958 "Cannot clear the object in use." on CLEAR ALL.

2. I discovered that if there is a modal form on screen, and Quit is issued in the on shutdown procedure, the form Unload code is executed ONLY for the modal form. The QueryUnload fires for each of the other forms, but the Unload is skipped when the quit is issued in this way.

I tested your code exactly as you sent it with quit in the on shutdown. This is what I observed with nested modal forms. Button clicks on form1Modeless calls test2modal, that calls test2amodal that calls test2bmodal.
*------Procedure stack at beginning of on shutdown.--------
FORM1.COMMAND3.CLICK
TEST2MODAL.COMMAND2.CLICK
TEST2AMODAL.COMMAND2.CLICK
ON... 
TERMINATEAPPLICATION
*-------------------------------
     
Releasing Form1
Form1 Release code executed
Releasing TEST2modal
TEST2modal Release code executed
Releasing TEST2amodal
TEST2amodal Release code executed
Releasing TEST2bmodal
TEST2bmodal Release code executed
TEST2bmodal Unload code executed

Forms collection after releaseallforms has released all 
_screen.forms(1) = TEST2amodal
_screen.forms(2) = TEST2modal
_screen.forms(3) = Form1
End of Forms collection 

Form1 QueryUnload code executed
TEST2modal QueryUnload code executed
TEST2amodal QueryUnload code executed
The UNLOAD event fired only for the one modal screen, but QueryUnload fired for each of the other forms, but not UNLOAD. I noticed the same thing on most other samples I looked at. I changed Quit to CLEAR EVENTS in TerminateApplication and placed CLEAR ALL and Quit just after READ EVENTS in my main program, reran the test program and this is the result.
*------Procedure stack at beginning of on shutdown.--------
FORM1.COMMAND3.CLICK
TEST2MODAL.COMMAND2.CLICK
TEST2AMODAL.COMMAND2.CLICK
ON... 
ON... 
TERMINATEAPPLICATION

*-------------------------------
       
Releasing Form1
Form1 Release code executed
Releasing TEST2modal
TEST2modal Release code executed
Releasing TEST2amodal
TEST2amodal Release code executed
Releasing TEST2bmodal
TEST2bmodal Release code executed
TEST2bmodal Unload code executed

Forms collection after releaseallforms has released all 
_screen.forms(1) = TEST2amodal
_screen.forms(2) = TEST2modal
_screen.forms(3) = Form1
End of Forms collection 

TEST2amodal Unload code executed
TEST2modal Unload code executed
Form1 Unload code executed
I use Unload event for clean up code in my forms but it was being skipped on shutdown. Putting clear all and quit in my main procedure after read events instead of ON SHUTDOWN procedure seems to be what I was missing.

Thanks for your help
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform