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

Running Aplication

Status
Not open for further replies.

TheBiker

Technical User
Jan 4, 2001
4
0
0
US
A rookie question: I made a project in VFP5
and it runs perfect while running inside VFP.

After building the application from VFP...
If I run its .exe file, it starts and then closes
automatically. What am I missing?

 
It's the old READ EVENTS problem.

There has been a thread about this recently in this forum.

Good hunting,


Weedz
veld4663@exact.nl

'It never hurts to help...' - Eek the cat.
 
I saw the read events comment but I don't know how to use it. Instead, I assigned the MODAL property to the main form and now it is running. I don't think this is the most efficient way to go. Any suggestions?
 
READ EVENTS will allow your application running even without main form. Say, users have main VFP window and menu at the top in it. They than can start from any form they want by choosing it from menu.


Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
*Sample Main program

*setup code*
*setup public*
*setup menus*
*setup connections*

*setup key traps*
ON KEY ALT+F4 DO pCloseApp

*setup event traps*
ON SHUTDOWN pCloseApp

DO FORM SomeFormName && not a modal form

*Foundation Read
READ EVENTS

PROCEDURE pCloseApp
ON SHUTDOWN &&Clear event trap
QUIT
ENDPROC

-Pete
 
I created a sample file like the one you showed and replaced SomeFormName with the name of the main form I am using (mainform), but I get an error saying:

Unrecognized command verb.

Also FOX PRO highlights the line that says
"ON KEY ALT+F4 DO pCloseApp"

If I remark the line that say pCloseApp I don't get the error any more. What am I doing wrong? Should I
define pCloseApp as a procedure first? If so, how?

If I don't make sense I'm sorry.

Thanks Pete
 
Try "ON KEY LABEL ALT+F4 DO pCloseApp" instead.

Rick
 
Sorry Biker, I should have tested my code before posting :-( Rick is correct the line should read:

ON KEY LABEL ALT+F4 DO pCloseApp

Sorry to add to your frustration. ;-)

-Pete
 
Hi guys!

What abot ON SHUTDOWN command? It works also when user presses Alt+F4.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
TomasDill, u ask about ON SHUTDOWN?

Imagine this:
What if user doesn't close your application while shutting down his/her computer?
Your application will be left hanging.

In my case:
My application doesn't quit until the user clicks the 1 & only 'QUIT' commandbutton in my form.
Thus, when the user is in a hurry to shutdown & forgot to close my application, my application will prompt 'Cannot Quit Visual FoxPro'. This is very frustating to the user.

So 2 prevent this frustration, ON SHUTDOWN tells your application what 2 do when user exits windows.

(If u already knew all this, just ignore this)
 
I think what Vlad means is that you do not have to issue an ON KELY LABEL ALT+F4 to your shutdown procedure.
This is already done by windows. (IN VFP the ON SHUTDOWN is called when pressing ALT+F4).

ALT+F4 is standard shutting down your application.

Issuing an ON SHUTDOWN DO closeApp, is enough. Even when you close your app with the task manager your procedure for shutting down is called.

So in your VFP app ON SHUTDWON is called in these cases:

Issuuing the command QUIT
Pressing the 'X'
Using ALT+F4
Closing your app from the task manager.

If you get the message 'Cannot quit Visual foxpro' your shutdown procedure does not shutdown your app in a good way.

A shutdown procedure should clear all objects (except for the application), all variables and close all databases, tables etc. and then close the application itself.
Weedz (The Grassman)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
"CAN NOT QUIT VISUAL FOXPRO" So long as your shutdown procedure clears the event trap you should not get this message... unless the form is model.

PROCEDURE pCloseApp
ON SHUTDOWN &&Clear event trap
QUIT
ENDPROC




-Pete
 
Alias, ON SHUTDOWN works when you shutdown windows.

When ON SHUTDOWN does not works, ON KEY LABEL definitely will not work. This might be in case when user opened some dialog window (for example, color selection) and left it opened. Either ON KEY LABEL Alt+F4 or ON SHUTDOWN will not work in such case. There are other cases when this will not work, for example, infiniive loop in routine. For infinitive loops ON KEY LABLEL works only when VFP.AutoYield contains proper value. ON SHUTDOWN works in such case too, and instead of 'Cannot quit foxpro' message ON SHUTDOWN routine will fire.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Ok, guys. I have not followed the messages because I was very
sick the last few days, but I will try it all later. Thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top