General information
Category:
Forms & Form designer
Cindy - thanks for the quick reply. I created a test form using your suggestion but I must have missed something. Two problems occur. If I close the form using the X, the CleanUpAndExit method fires but the form closes anyway. If I click on a Command Button that triggers the CleanUpAndExit method and my test condition is false, I get "Allowed DO nesting level exceeded" error. My CleanUpAndExit method looks something like this:
If lcondition = .t. && Don't close form
thisform.cmd1.setfocus
else
thisform.release
endif
Thanks again for your help and patience.
>Ken,
>
>There are two ways to close a form - by calling THISFORM.Release(), (often code in an Exit button) or by the X, which fires QueryUnload(). Ultimately you must make sure your test runs by either close method.
>
>The best thing to do is to make a custom method like CleanUpAndExit() and put your test to see if you want to close in there. In each of the Release() and QueryUnload() methods, call THISFORM.CleanUpAndExit().
>
>You might put CleanUpAndExit in your base form class, and also the calls to it. Then in each form put whatever code you want to run when you clean up.
>
>If you don't want to exit, return .F. from CleanUpAndExit and SETFOCUS to whatever control you need to.
>
>
>>Is there a way to test for a condition (eg. unsaved changes) when a form is closed (ie. user clicks the close icon on top right of form), abort the closing of the form and reset focus to a control?
>>Thanks.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only