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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP and App will not shutdown

Status
Not open for further replies.

letsgotovegas

Programmer
Feb 3, 2005
19
0
0
US
Hi
Below is my code. The problem is my application will not shutdown. And then when I try to quit vfp it will not shutdown either.

This is in my main prg.

Code:
PUBLIC frmMain as Object 




SET PATH TO HOME(1);MENUS;classes;libs;DATA;SOURCE;OTHER;graphics;FORMS;OTHER
ON SHUTDOWN DO closedown
SET CLASSLIB TO clsForms.vcx
frmMain = CreateObject("MainForm")
frmMain.Show
READ EVENTS

This is my shutdown procedure

Code:
PROCEDURE CloseDown()
	SET SYSMENU TO DEFAULT
	frmMain.Unload
	CLEAR EVENTS
	CANCEL
RETURN

Kind Regards
John

To much of a good thing - is a good thing!
 
Hi John,

frmMain.Release instead of Unload

I usually put CLEAR EVENTS in the Destroy of my main form.

Regards,

Mike
 
John,
It's also always a good idea to "kill" the ON SHUTDOWN in that routine:
Code:
PROCEDURE CloseDown()
    [red]ON SHUTDOWN[/red]
    SET SYSMENU TO DEFAULT
    frmMain.Release()
    CLEAR EVENTS
    CANCEL
RETURN
Rick
 
Thanks Rick and Mike. ON SHUTDOWN was the key. And RELEASE instead of Unload.


Kind Regards
John

To much of a good thing - is a good thing!
 
The Cancel is quite useless, because CLEAR EVENTS will take foxpro back to what comes after READ EVENTS. So you may even make it ON SHUTDOWN CLEAR EVENTS and put the code you want to do after the READ EVENTS line.

But: That has a problem, if you're stuck at the moment of "shutdown", eg through a MESSAGEBOX() running at that time. It's not that easy if it comes to special cases. But if it ain't broke, don't fix it. So if that works for you, it's okay...

Bye, Olaf.
 
I usually use a QUIT instead of CANCEL. It's not forgiving if your in dev mode, but it does seem to work more reliably. Also, with the QUIT, the ON SHUTDOWN is not needed, but still recommended.
 
You shouldn't need QUIT or CANCEL at the end of the main program of an application. When you reach the end of the program, it ends. Something like this (extremely simplified) should work:

* Set up code, such as SET commands

* Start menu:
DO MainMenu.MPR

* Start event loop
READ EVENTS

* Clean up code

RETURN

Tamar
 
Thanks everybody. I now have my shutdown routine down perfect. I just had to understend the read events. Clear events clears this and continus on to the next line of code. I went ahead and put my cleanup code in my shutdown procedure. Could of put it after read events also. I have got my beginning shell of a program on track. No more "Foxpro can not quit" or other hangup errors any more. Thanks for all the help. This forum is one of the best I have ever been on. And the design is really effecient also. All the replies are on 1 web page. Really nice.

Kind Regards
John

To much of a good thing - is a good thing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top