开发者

My Visual FoxPro application appears to close... but is still running in the Task Manager

开发者 https://www.devze.com 2023-03-15 18:41 出处:网络
My FoxPro program has a quit button and the usual min/max/X buttons in the top right, and when using either the program disappears and seems to have closed properly.However, when I check my Task Manag

My FoxPro program has a quit button and the usual min/max/X buttons in the top right, and when using either the program disappears and seems to have closed properly. However, when I check my Task Manager, I find that it开发者_开发知识库 is still running.

This is my main.prg file:

ON SHUTDOWN CLEAR EVENTS
with _screen
.visible = .f.
endwith

DO FORM locations\form1
READ EVENTS
ON SHUTDOWN 

and this is the code for my exit button 'click' event:

unlock all
close database all
clear events
RELEASE ALL
quit

My program has only the one form and it's set as top-level... any suggestions as to how I can fix this?

Thanks for your time and help :)


If you are running VFP originating from the IDE (Development environment), and you do _Screen.Visible = .F., you are HIDING the main VFP screen, and the system may be returning directly to that, and since you can't see it, you cant formally quit.

In your MAIN.PRG, put the following down at the bottom as a separate "function" that will be visible within the call stack.

function CloseMyApp
   */ For now, just to "ignore" any errors of any dangling objects trying to get released
   */ and otherwise might be HIDING an error upon shutdown.
   on error *

   */ NOW, clear the event handler and close everything else down
   clear events
   close database all
   close tables
   on shutdown 

   quit
endfunc 

Then, in your start, change your ON SHUTDOWN to call this "function"... Right now, you are only issuing a single command of clear events. This way, you can wrap up a bunch of "cleanup" operations before closing, and not just clearing the read events.

ON SHUTDOWN Do CloseMyApp in Main.PRG


If you click the EXIT button on the form (your button) does the form close and the application close correctly ?

If it does, ASSUMING the button is called 'cmdExit' then add this line to the 'UNLOAD' event of the form

THISFORM.cmdExit.click()

0

精彩评论

暂无评论...
验证码 换一张
取 消