I'm starting a new project in VFP 9
In past projects I've not included a ControlBox on forms opting instead for an "Exit" button on the form. However for this project, I'd like to include the Control Box.
I have been unable to find documentation on the order of events that occur after the user selects 'Close' from the control box (or a click on the 'X')
Based on tests, I know that the Destroy Event occurs prior to Unload. But, are there other events and what is the preferred means/location for intercepting the call to close the form when data has not been saved? Is there a way to cancel the call programatically? Would I need to place code in the valid event of every control on the form?
For now, in the Destroy Event of the form, I've placed the following code but I'm interested in knowing what others are doing and what is considered 'Best Practice'
Thanks in advance for your help.
CDavis
In past projects I've not included a ControlBox on forms opting instead for an "Exit" button on the form. However for this project, I'd like to include the Control Box.
I have been unable to find documentation on the order of events that occur after the user selects 'Close' from the control box (or a click on the 'X')
Based on tests, I know that the Destroy Event occurs prior to Unload. But, are there other events and what is the preferred means/location for intercepting the call to close the form when data has not been saved? Is there a way to cancel the call programatically? Would I need to place code in the valid event of every control on the form?
For now, in the Destroy Event of the form, I've placed the following code but I'm interested in knowing what others are doing and what is considered 'Best Practice'
Code:
IF THISFORM.RELEASETYPE=1 && User Clicked the "X" to Close the Form
cMessageTitle = ' Caution '
cMessageText = "Information Has Not Been Saved" ;
+ CHR(13) +CHR(13) + "Do You Want to Save Now?" ;
+ CHR(13) + CHR(13) ;
nDialogType = 4 + 16 + 0
* 4 = Yes & No buttons
* 16 = Stop Sign icon
* 0 = First button is default
nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle)
DO CASE
CASE nAnswer = 7 && No Button Pressed
=TABLEREVERT(.T.,"Eval")
OTHERWISE
*** Yes Button Pressed -- Process Information & Save
*
*
ENDCASE
ENDIF
Thanks in advance for your help.
CDavis