Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for changes when a FORM closes
Message
From
26/02/2003 12:35:47
 
 
To
26/02/2003 09:18:18
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00756892
Message ID:
00758232
Views:
24
James,

Up until this last year, our apps have been relatively modal due to the complexity of managing the forms,menus,toolbars and such. The app we are updating has been/is used in 1000+ locations for about 6 years now and we just haven't had time to make the change to a fully non-modal app. Now it's time.

I guess I should have done a follow up message on how I actually coded the forms. I was a little frustrated the other night (and venting a little) when I realized how many ways there were to close a form and that when the object var goes out of scop there is no way to stop it.

It's not really that complicated now that I understand there are three ways a form can close and they have different paths they follow on their way out.

The User/System Closes it. (QueryUnload)
The way I normally Closed it. (Release)
The Object Var goes out of Scope. (Destroy)

Like you, I added a custom method to my base form class that checks to see if it is ok_to_close the form. I won't directly call the QueryUnload Event either.

I did add one thing: I pass a parameter to the ok_to_close method that will allow me to skip the checking if needed. Yes, I could call the release method to close the form directly, but I wanted ONE standard call to close any form.

I call the ok_to_close method from the queryunload event to catch all of the ways the user may close the form and I call ok_to_close in in the menus, toolbars or code when I want the form to close. The only thing left to do is to make sure one or the other gets called before the Object var goes out of scope.

In the ON SHUTDOWN routine, I loop through all of the open forms and call the ok_to_close method BEFORE I let the app close. Each form then decides on it's own or asks the user if it should close. For forms that call a child form, I put code in the ok_to_close to close each of it's child forms before it can close.

My goal was to have one standard way of closing every form in the app and to have the form responsible for deciding on it's own or asking the user if it was ok_to_close unless I told it otherwise.


I know there are frameworks for this stuff :).


Jim



>Jim,
>
>I've been doing this for years, but never stopped to analyse the process as you have. Very enlightening. Thanks.
>
>However, I never call queryunload() explicitly, and it always seems to work nonetheless.
>
>I have a method, m_Close() which takes care of saving changes and general cleanup when a form closes. I call it from queryunload() thusly,
>
>IF !( thisform.m_Close() )
>   NODEFAULT
>ENDIF
>
>RETURN
>
>Again thanks for the information.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform