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

Shutdown

Status
Not open for further replies.

gshurman

Programmer
Oct 27, 2001
25
US
Does anyone have a procedure that allows the user to click on the X on the screen form and ask if they want to quit? If they don't want to quit it should return to where it was when the X was clicked.
 
Try something like the following in the QueryUnload event of the form...it is really simple and you could certainly augment it.

Code:
IF MESSAGEBOX("Do you really want to quit?",36,"QUIT?") = 6
	DODEFAULT()
ELSE
	NODEFAULT
ENDIF

...if it is the _screen object you are trying to get to then you could use bindevent with the _screen's queryunload (I would think) or in pre-vfp8 you could certainly put some code in a shutdown routine and use ON SHUTDOWN command to make sure that routine is called when the user tries to exit your application...in that routine you would make sure the user is asked before the program exits. What version of VFP are you using and is it a form you've created you want this to work for or for the _screen?


boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
gshurman

I use the following in MDI interfaces where clicking on the X of the _SCREEN object is the preferred means of closing the application.

In the body of main.prg
Code:
[COLOR=blue]ON SHUTDOWN DO CloseApp[/color]

In the CloseApp procedure
Code:
[COLOR=blue]PROC CloseApp
IF MESSAGEBOX([Do you really want to quit?,;
[tab][tab]4 + 32 + 0,;
[tab][tab][Close application]) = 6
[tab]CLEAR EVENTS
[tab][/color][COLOR=green]* Cleanup code[/color][COLOR=blue]
[tab]QUIT
ENDIF[/color]
By placing CLEAR EVENTS in the CloseApp procedure, it's easy to cancel out.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Thanks for the reply. I'm using VFP 8. I'm trying to allow the user to have the option of closing the VFP app by clicking on the close box in the upper right. After the "Do you want to quit?" message if the answer is No, I want to resume the application.
 
gshurman

gshurman said:
After the "Do you want to quit?" message if the answer is No, I want to resume the application.

Try the code posted - that's what happens.

As you do not issue CLEAR EVENTS until the user has confirmed they want to quit, the application continues to run.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Try this!

Screen.Closable = .t.
On ShutDown Clear Events

Do Form [login_form]

Read Events
On ShutDown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top