Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
QueryUnload or Release?
Message
 
To
24/11/2003 21:07:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00853142
Message ID:
00853153
Views:
24
Hi Tracy,

All you need is to have your clean-up code (or a call to a clean-up method) only in the QueryUnload method. The form close button X calls QueryUnload before releasing the form. Thus, the QueryUnload method would look something like this:
LOCAL llReturn
IF Everything_OK()  &&in the clean-up method
    llReturn = .T.
ELSE
    NODEFAULT
    llReturn = .F.
ENDIF
RETURN (llReturn)
Also, the other commandbuttons closing the form would just verify IF QueryUnload() before calling Thisform.Release()


>Hi Hilmar,
>
>Thanks. I gotit and that is what I ended up doing, however, in order to account for the user clicking on the close button, cancel button, etc or clicking on the form's 'X' button in the top-right corner, I am still calling the form's cleanup method from both the release and the queryunload method. Seems like duplication even if just the call to the method has to be entered in both. There must be a better way?
>
>
>>I may be wrong, since the framework I use manages these nasty details. However, I think it would look something like this:
>>
>>In QueryUnload(): If the user confirms that he wants to exit, go ahead and run your cleanup code. Otherwise, I think you need to insert a NoDefault. In Release(), you must also call your cleanup code.
>>
>>I am not sure whether it is convenient to put all your cleanup code into Form.Release(), or whether you better create a separate cleanup method; I think the latter is the case. Actually, I think the cleanup code will only call ThisForm.Release() if some conditions are met, for instance: user confirms (if this is considered relevant) that he wants to exit; and there are no pending (unsaved) changes (for instance, if the user is asked "Save?" and replies by pressing the "Cancel" button, the changes will still be pending).
>>
>>HTH,
>>
>>Hilmar.
>>
>>>I have always used thisform.release in my command buttons that close a form so that I can access form properties if I need to before releasing all of the form's objects. However, I would like to allow the user to click on the 'X'in the top right hand corner of the form to also close the form and do some checks to determine if the form should be closed or not. Typically, this would be the same as pressing escape so I am prompting the user to exit the form or not and return to the form if necessary to continue editing so the user can save his changes. In testing, I noticed that clicking on the x does NOT run the form's release method, but queryunload. Hence, code that I had in the form's release method will have to be moved to queryunload. Yet calling queryunload from a command button does not seem to close the form. What is the best way to handle this? I don't want to put duplicate code in both queryunload and release...
>>>
>>>TIA!
Previous
Reply
Map
View

Click here to load this message in the networking platform