Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quit Visual Foxpro - Windows shutdown

Status
Not open for further replies.

SnyAc

Programmer
Jul 25, 2001
272
US
Another quirk to the 'Cannot quit Visual Foxpro' message. I have all of the suggested code in my app but when windows tries to close the app when windows is shutting down, I get the CQVP message.....

Any suggestions????

thanks

Andy Snyder
SnyAc Software Services
 
Try this to KILL the current process. I'm not sure where the best place for it is though.

DECLARE Integer ExitProcess IN Win32API
ExitProcess()

Brian
 
I guess the real question is what method is triggered when Windows requests a shutdown....

If I knew that... I'd know where to put the CLEAR EVENTS.... etc.


Andy Snyder
SnyAc Software Services
 
Do you have an ON SHUTDOWN CLEAREVENTS command?

Brian
 
Yes.... in the following fashion....

ON SHUTDOWN DO QuitSnyAc WITH .T.

PROCEDURE QuitSnyAc
lparameters NoAsk
if !NoAsk
nQkey=msgwindow('Shutting down '+left(_screen.caption,at(' ',_screen.caption))+chr(13) ;
+' in 10 seconds.',.T.,'','OK/Shut Down;Cancel',10)
if nQkey<>1
return
endif
endif
release windows all
clear events
on shutdown
on error wait window nowait message(1)
if _vfp.StartMode=0
return to master
endif

quit


Andy Snyder
SnyAc Software Services
 
Try replacing the 'quit' with the lines I suggested. It won't care if VFP thinks it can or can't quit.

Brian

DECLARE Integer ExitProcess IN Win32API
ExitProcess()
 
Nope.... that didn't do it.... still get the CQVP message....

Once again I guess I'm still wondering what method is triggered when Windows tells a process to shutdown....

Andy Snyder
SnyAc Software Services
 
SnyAc

It is unclear exactly what the problem.
Is the problem, &quot;when you close you application normally, and then close windows, you still get the message&quot;.

Or is it, &quot;when you try to close window and your application is still running, you get the message&quot;.

If its the first problem, use the task manager to see if you have more than one instance of your application running.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
You missed the conditions entirely Mike. I'm not closing the application, I'm shutting down Windows with the application still running. Windows is telling the application to quit. This situation can arise quite often if your app is running minimized or on the system tray.



Andy Snyder
SnyAc Software Services
 
SnyAc

You missed the conditions entirely Mike.

Really? I thought I described it quite well when I asked when you try to close window and your application is still running, you get the message&quot;.

Once again I guess I'm still wondering what method is triggered when Windows tells a process to shutdown....

In answer to this, I would assume that Windows goes through a series of checks using API calls ,like enumerating running processes ( and trying to kill them one at a time.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike, I never said 'when you try to close the application'. My original post says 'when Windows tries to close the app'.

Ok.... so back to the same conditions and question again.... when Windows attempts to end a process/application.... what method is triggered in the top level form. If I knew that I'd know where to put the shutdown call to prevent the CQVP message.

Andy Snyder
SnyAc Software Services
 
SnyAc

This thread doesn't seem to get anywhere fast.

I said when you &quot;try to close windows with the application still running&quot;. Windows most likely goes through a series of API calls to determine what processes are running and tries to shut them down. I'm not sure why this answer seems to not satisfy your question. Since you are not closing the application through VFP, then it would stand to reason Windows is trying to close it, so the process of closing your VFP application is handle by Windows not VFP.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Andy,

What is it that you program is doing at that time? Perhaps you can allow your program to 'rest' while it isn't in use?

Brian
 
Actually I wouldn't know what my program would be doing.... after all this situation occurs when the user wants to turn his machine off and doesn't bother to close his open applications....

I understand how to keep the CQVP message from happening when the user exits the application, whether it's by using the Quit option on the menu or by clicking the close box on the top level form.... that has been working fine for over a year.

Andy Snyder
SnyAc Software Services
 
I was able to duplicate your issue by putting VFP in a do while loop, but I don't haven't had an issue with it myself otherwise. Maybe the app is still updating, calculating, saving or reporting? Maybe a progress window for those tasks (with a message that data could be lost if it isn't allowed to finish) would stop the users from being so quick to shutdown.

Brian
 
SynAc,

I would try logging what's happening in your code to make sure each branch of your QuitSynAc() function is getting executed.

Here's what I use for quick and dirty logging:

strtofile(&quot;<message>&quot; + chr(13)+chr(10), &quot;<logfile>&quot;, .T.)

So in your case you might use:

strtofile(&quot;step 1&quot; + chr(13)+chr(10), &quot;synac.log&quot;, .T.)

I would place a bunch of these log file messages in my code, attempt to shutdown Windows, and then review your log file to see which statements are actually getting executed.

Good luck!
Malcolm
 
Andy,

I've been doing some research and apparently having a modal form will also cause the CQVP message. Since the windowtype property is apparently read only in runtime, you'll need to explicitly release all of your running modal forms in the ON SHUTDOWN procedure.

Brian
 
Here's a simple way to do it:

DO WHILE _Screen.FormCount>0
_Screen.Forms(1).Release
ENDDO

Brian
 
what about setting the form(s) to &quot;modeless&quot; (my predefined standard) in stead of modal?

wilfredo
 
Problem has been solved.... Thanks to all of you for your suggestions, this turned out to be a 'programmer brain fart' error. (I had neglected to put my usual ON SHUTDOWN line in init section of the app)

I apologize for the confusion... I didn't think that I had a problem with this issue (since I have several other apps that Windows can close)... but I couldn't seem to find the missing piece.


Andy Snyder
SnyAc Software Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top