The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a
SUMMARY
Exitfox.exe is a sample that illustrates some situations where the "Cannot
Quit Visual FoxPro" error message may appear and a way to overcome this
error message.
MORE INFORMATION
The following file is available for download from the Microsoft
Software Library:
~ Exitfox.exe (size: 51870 bytes)
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591
TITLE : How to Obtain Microsoft Support Files from Online Services
There are two common reasons why the "Cannot Quit Visual FoxPro" error
message may be encountered. The first is that there is a READ EVENTS active
when the QUIT command is issued. The second is that there is a modal forms
active when the QUIT command is issued.
In Visual FoxPro 3.x, the QUIT command would process through a modal form
or a READ EVENTS to exit an executable. Although the error could still be
encountered, if, for instance, the application's CloseBox is clicked when a
READ EVENTS is in effect. In Visual FoxPro 5.x, the QUIT command will not
process through either a modal form or a READ EVENTS.
The sample files contained in this article both illustrate some possible
scenarios where the error message may be encountered and a way around it.
Either Visual FoxPro 5.0 or the professional version of Visual FoxPro 3.0
are needed to work with these files. Although Visual FoxPro 3.0 users will
not likely run into the error message in the situations that are
illustrated herein. The Visual FoxPro runtime libraries are not included
with the sample files. To run the executable files, the runtime libraries
must be present. The steps below will assume that Visual FoxPro 5.0,
including the support library, are on the computer in use.
To use the sample files, follow these steps.
- Place the ExitFox.exe self-extracting executable file in a new folder
and double-click it to extract the files.
- The following files are contained in it:
- Quitfox.pjx
- Quitfox.pjt - These are the Visual FoxPro 5.x project files.
- Quitfox3.pjx
- Quitfox3.pjt - These are the Visual FoxPro 3.x project files.
- Quitfox.exe - Sample custom exe file - Visual FoxPro 5.x.
- Quitfox3.exe - Sample custom exe file - Visual FoxPro 3.x.
Both projects share the following files:
- Quitfox.prg - The main program in both projects.
- Quitfox.scx
- Quitfox.sct - The first modal form in each project.
- Quitfox2.scx
- Quitfox2.sct - The second modal form in each project.
- Quitfox.mnx
- Quitfox.mnt - The menu files for each project.
The forms, menu, and main program are common to each project. There are
no version-specific settings or code in either project. The executables
can be rebuilt in each version of Visual FoxPro as desired. Open the
appropriate project file for the version of Visual FoxPro in use. Using
the same files in both projects illustrates the difference in
behavior between version 3.0 and version 5.0.
- Run the Quitfox.exe file. It should display the Visual FoxPro screen
with a menu containing the Quit, Do Modal Form and AllowCloseBoxExit
options.
- Try to close the application with the CloseBox in the upper right
corner. The "Cannot Quit Visual FoxPro" error message should appear.
This is because there is a READ EVENTS in effect. The same behavior will
happen in Quitfox3.exe. The Quit menu command or F11 can be used to
exit the application if desired. To allow the application to be
shutdown with the CloseBox, choose the AllowCloseBoxExit menu option,
which issues an ON SHUTDOWN CLEAR EVENTS command. Instead of issuing
this in a menu option, it could be placed at the beginning of the main
program in the project. Then the CloseBox could be used to exit the
application without choosing the menu option. This can be disabled by
setting the Closable property of _Screen to .F. as is done in the Do
Modal Form menu option. "_Screen" is made closable again in the
Destroy method of Modal Form #1. This is where the similarities in
quitting the two applications end.
- Now choose the Do Modal Form menu option. Modal Form #1 should appear.
It can be closed with the CloseBox or the Close Form button. Try the
Quit FoxPro button. The "Cannot Quit Visual FoxPro" error should appear.
If running Quitfox3.exe, this will exit the application.
- Next click the Do Another Modal Form button. Modal Form #2 should
appear. Try closing it with the Quit FoxPro button. In Quitfox3.exe,
this will end the application. In Quitfox.exe, it produces the error
message. Try the Hide Modal Forms and Quit button. This hides the
modal forms, which makes them modeless, so the QUIT command will then
work. The form can be closed with the CloseBox in the top right corner
if quitting is not desired.
- With Modal Form #1 active, increase the value in the Spinner control to
5. There is a timer control on this form. The Interval property is
initially set to zero to disable it. With the Spinner's value set to 5,
click on the Set Timer Interval To Spinner Value button. The timer will
now fire in 5 seconds. The timer calls a procedure in the main program
that releases all open forms and does a CLEAR EVENTS. The application
should now disappear after waiting 5 seconds. As a further test, the
second modal form can be displayed before the timer fires. The
application will still quit. Although not needed in a Visual FoxPro 3.x
executable, this method works there too.
- Open the source files and examine the code and settings.
The technique employed here could easily be modified for a multi-user setup
where a table on a server holds a value that determines if the application
should be ended. The procedure that the timer calls would go out and check
that value and determine whether or not to end the application. An
administrator could set the value at night, for instance, to log out any
users who left for the day with the application running. Once all the users
are logged out, the administrator could open the application's tables
exclusively and PACK, REINDEX, or change their structure.
Keywords : FxprgGeneral vfoxwin kberrmsg
Version : WINDOWS:3.0,3.0b,5.0,5.0a
Platform : WINDOWS
Issue type : kbfile
Solution Type : kbsample
|