I saw the read events comment but I don't know how to use it. Instead, I assigned the MODAL property to the main form and now it is running. I don't think this is the most efficient way to go. Any suggestions?
READ EVENTS will allow your application running even without main form. Say, users have main VFP window and menu at the top in it. They than can start from any form they want by choosing it from menu.
I created a sample file like the one you showed and replaced SomeFormName with the name of the main form I am using (mainform), but I get an error saying:
Unrecognized command verb.
Also FOX PRO highlights the line that says
"ON KEY ALT+F4 DO pCloseApp"
If I remark the line that say pCloseApp I don't get the error any more. What am I doing wrong? Should I
define pCloseApp as a procedure first? If so, how?
Imagine this:
What if user doesn't close your application while shutting down his/her computer?
Your application will be left hanging.
In my case:
My application doesn't quit until the user clicks the 1 & only 'QUIT' commandbutton in my form.
Thus, when the user is in a hurry to shutdown & forgot to close my application, my application will prompt 'Cannot Quit Visual FoxPro'. This is very frustating to the user.
So 2 prevent this frustration, ON SHUTDOWN tells your application what 2 do when user exits windows.
I think what Vlad means is that you do not have to issue an ON KELY LABEL ALT+F4 to your shutdown procedure.
This is already done by windows. (IN VFP the ON SHUTDOWN is called when pressing ALT+F4).
ALT+F4 is standard shutting down your application.
Issuing an ON SHUTDOWN DO closeApp, is enough. Even when you close your app with the task manager your procedure for shutting down is called.
So in your VFP app ON SHUTDWON is called in these cases:
Issuuing the command QUIT
Pressing the 'X'
Using ALT+F4
Closing your app from the task manager.
If you get the message 'Cannot quit Visual foxpro' your shutdown procedure does not shutdown your app in a good way.
A shutdown procedure should clear all objects (except for the application), all variables and close all databases, tables etc. and then close the application itself.
Weedz (The Grassman)
veld4663@exact.nl
They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.
"CAN NOT QUIT VISUAL FOXPRO" So long as your shutdown procedure clears the event trap you should not get this message... unless the form is model.
PROCEDURE pCloseApp
ON SHUTDOWN &&Clear event trap
QUIT
ENDPROC
Alias, ON SHUTDOWN works when you shutdown windows.
When ON SHUTDOWN does not works, ON KEY LABEL definitely will not work. This might be in case when user opened some dialog window (for example, color selection) and left it opened. Either ON KEY LABEL Alt+F4 or ON SHUTDOWN will not work in such case. There are other cases when this will not work, for example, infiniive loop in routine. For infinitive loops ON KEY LABLEL works only when VFP.AutoYield contains proper value. ON SHUTDOWN works in such case too, and instead of 'Cannot quit foxpro' message ON SHUTDOWN routine will fire.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.