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

VFP auto-shutdown

Status
Not open for further replies.

chpicker

Programmer
Apr 10, 2001
1,316
I created a program that runs in the background. It runs on a timer to watch for new files in a given folder and act upon them. I used the FoxTray program that I had found a couple of years ago (I don't remember where offhand) to give me an icon in the system tray so I can shut it down when I need to.

All of my shutdown code is in the CLOSEAPP.PRG file. This is all it does:
Code:
[COLOR=blue]ON SHUTDOWN[/color] [COLOR=green]&& Disable further shutdown attempts[/color]
[COLOR=blue]CLEAR EVENTS[/color]
My main program executes "ON SHUTDOWN DO closeapp" just before the READ EVENTS command.

The only menu command attached to the FoxTray icon is "Shut Down" which executes "DO CLOSEAPP".

Everything appears to work fine. If I select "Shut Down" from the menu, the program closes almost instantly. If I bring up the task list immediately afterward, it's no longer listed.

Here's the odd part: if I try to shut down Windows, all of my programs, including this one, shut down just fine...but Windows doesn't! I have to shut down Windows a second time to get it to do so.

I am using VFP 7.0 with SP1. The computer is running Win98SE. This problem is infinitely repeatable. Every time I select "Shut Down" (or Restart, or Log Off) it shuts down my programs, but goes right back to the desktop...ONLY if this one program is running! If I re-launch the program and try to shut down, it again just kills the program and goes back to the desktop. Is VFP somehow telling Windows to abort the shutdown even though it exits properly? Is there anything I can do to fix this?

Ian
 
Do you have a QUIT anywhere in your app?
Also, is it in fact just going back to the desktop or are you attempting to restart the second time before the 'End program' dialog comes up?
It doesn't sound like the programs (either your app or the fox tray thing) are getting shut down properly, at least in the eyes of Windows.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
No QUIT anywhere, I just CLEAR EVENTS and let the Main program end. And yes, I'm absolutely positive that the program has exited. The last thing I have in the program is _screen.visible=.T. which causes the main VFP window to flash up and disappear. The program quits almost instantly, so it's not timing out. There's no actual cleanup necessary...just a form to release which contains the OCX for the system tray icon and 2 timers.

The only thing I can think of is that Windows, when posting the shut down message to VFP, is getting a return value from VFP that tells it to abort. Maybe it's a bug in 7? I haven't tried it with any of my other programs.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top