Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Form.release question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00228761
Message ID:
00229409
Vues:
17
>I see. I personally find it more intuitive to do things in the Destroy procedure. Then you don't have to remember that everywhere and anywhere in your code you release the form, you have to first run Queryunload. There may be times when you only want to run code when the user closes the form by other than a Release; this is where you would use Queryunload. But when you want to run code everytime the user closes the form, no matter how the closing is done, I think it should go in the Destroy procedure. That is why the event is available to us.

Ordinarily, it makes no difference. You have a button to Close a form with thisform.release, fine, it does exactly the same thing as a titlebar close. When it does make a difference is in a top-level, which requires a CLEAR EVENTS somewhere for shutdown. For that special case, I use the queryunload in the same way that a non-TL uses an ON SHUTDDOWN procedure, to clean up references, possibly call a Save type method, save some system settings, etc. I may want to stop it, too, with a Nodefault there. The Queryunload gives more flexibility, since the Destroy is too late.

For this scenario, the only line of code in the destroy would be CLEAR EVENTS, and I have no argument with putting it there, I just prefer to keep it with the rest of the code...


>Don't you think there is a danger that somewhere down the road another programmer will add a button to the form that is a new option and does something and then performs a Release on the form? If he/she is not aware of the code in Queryunload, the code will not be run and that is obviously a problem. I just see no advantage to using Queryunload over Destroy in this case, and I see a disadvantage. I am assuming that I understand the situation correctly.

He/she will quickly become aware of the Queryunload code when the app does not shutdown properly :) Anyway, the same could be said of a Destroy Clear Events, if someone attempts to use the form as a non-terminating form, and wonders why the app shuts down when clicking on a close, I guess...
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform