Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Closing all forms cleanly using ON SHUTDOWN
Message
De
04/06/2004 17:19:08
 
 
À
04/06/2004 17:07:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00910147
Message ID:
00910154
Vues:
32
This message has been marked as the solution to the initial question of the thread.
Hi Tracy,

I think I picked this tip up from the FoxPro Advisor a while back. Perhaps what you are looking for?
DECLARE Integer ExitProcess IN Win32API
ExitProcess()
John

>We have many forms. Over 400 in fact. Some use the queryunload and some use a separate close method and some have code in the release. There may be a time when we want to close all open forms regardless of pending writes and close all tables and not prompt the user at all. It is important to release everything and get out without corrupting data and prompting the user. In this case, we do not care if pending writes are lost. However, due to the uniqueness of the different forms, using queryunload or release can at times prompt the user for input. This is done on many forms in case the user clicks on the X in the top right corner of the form during data entry to exit and we want to prompt him/her to save or cancel etc but it creates a problem for a complete programmatic shutdown. any ideas?
>
>Here is testing code that isn't working due to code in queryunload, release etc of forms (sometimes it will actually produce a C5 error):
>
>
>PROCEDURE CloseApp
>
>WAIT WINDOW "System shutdown initiated." NOWAIT
>
>PRIVATE lans
>lans=0
>lans=MESSAGEBOX('You have started shutting down your computer'+CHR(13);
>               +'without saving all information and exiting'+CHR(13);
>               +'Policy Profiler Windows first.'+CHR(13)+CHR(13);
>               +'If you continue, your changes will not be'+CHR(13);
>               +'saved and your computer will shutdown.'+CHR(13)+CHR(13);
>               +'Select OK to exit Policy Profiler and'+CHR(13);
>               +'shutdown your computer or select Cancel to abort'+CHR(13);
>               +'the shutdown and return to Policy Profiler to'+CHR(13);
>               +'save all changes first.'+CHR(13)+CHR(13);
>               +'Exit Policy Profiler Windows and shutdown computer?',1+32+256+4096,'System Shutdown Initiated')
>IF lans<>1	&& 1=OK
>	WAIT WINDOW "Shutdown aborted.  Please save all changes and exit before shutting down." NOWAIT
>	RETURN	&& return to location in app to allow user to exit cleanly
>ENDIF
>
>WAIT WINDOW "Shutting down Policy Profiler" NOWAIT
>
>DO signout
>
>FOR EACH loForm IN _VFP.FORMS
>	IF VARTYPE(loForm) = "O"
>		loForm.RELEASE()
>	ENDIF
>ENDFOR
>
>CLEAR events
>ON ESCAPE
>ON ERROR
>ON SHUTDOWN
>CLOSE TABLES
>RELEASE ALL
>
>QUIT
>
>and
>
>WAIT WINDOW "Shutting down Policy Profiler" NOWAIT
>
>DO signout
>
>PRIVATE llokay
>llokay = .T.
>FOR EACH loForm IN _VFP.FORMS
>	IF VARTYPE(loForm) = "O"
>		IF loform.QUERYUNLOAD()
>			loForm.RELEASE()
>		ELSE
>			STORE .F. TO llokay
>		ENDIF
>	ENDIF
>ENDFOR
>IF !llokay
>	=MESSAGEBOX('An Error Ocurred Attempting to Exit.',0+16+4096,'ERROR')
>	RETURN TO MASTER
>ENDIF
>
>CLEAR events
>ON ESCAPE
>ON ERROR
>ON SHUTDOWN
>CLOSE TABLES
>RELEASE ALL
>
>QUIT
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform