How to Manage the Exiting Process with QueryUnLoad EventLast reviewed: April 4, 1996Article ID: Q131181 |
The information in this article applies to:
SUMMARYWhen a user attempts to leave a form, you want to query the user to ensure that they really want to leave the form. Using the QueryUnload event of a form, you can ask the user, and then take appropriate action in response.
MORE INFORMATIONAs described in the Help menu, the QueryUnload event occurs before the Destroy event. The ReleaseType property is set prior to the QueryUnload event being called. The QueryUnload event occurs when:
The following table summarizes the values for the ReleaseType property and indicates when the QueryUnload event is called.
Action ReleaseType Value QueryUnload Called? QUIT 2 Yes CLEAR WINDOWS 1 Yes RELEASE WINDOWS 1 Yes Click in Close Box 1 Yes RELEASE thisform 0 NoNote that the QueryUnload event is not called when a RELEASE thisform command is called. Therefore, if you are using the RELEASE thisform command as a means of exiting a form, you won't be able to use the code example below in the QueryUnload event; you'll need to use an alternate method to achieve the same result.
Code SampleThe following code sample demonstrates how to use the QueryUnload event in a form:
*--------------------------------------------------------------* * Program: QUNLDTST - QueryUnload test code * * Purpose: Demonstrates trapping user exit from form. * *--------------------------------------------------------------* cMessageTitle = 'Test' cMessageText = 'Did you *really* mean to close this form?' nDialogType = 4 + 32 + 256 * 4 = Yes and No buttons * 32 = Question mark icon * 256 = Second button is default nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle) DO CASE CASE nAnswer = 6 RELEASE THISFORM CASE nAnswer = 7 NODEFAULT ENDCASEThe use of NODEFAULT in the DO CASE construction overrides the default action of closing the form, in effect canceling the user's actions.
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |