Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shutdown
Message
De
15/09/2005 10:13:08
 
 
À
15/09/2005 09:13:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01049813
Message ID:
01049855
Vues:
20
>Of all things, I am having trouble with quitting an app. (Cannot Quit Visual FoxPro)
>The code I use works fine in one program and not in another. I am looking for a more reliable shutdown procedure.
>
>Your Pal

Try this:

In QueryUnload Method:
if program( program(-1) - 1 ) # 'SHUTDOWNFORMS'
	*
	do downshut
endif
PROCEDURE DownShut
if ShutDownForms( .T. )
	*
	release popups
	release menus
	*
	on shutdown
	clear events
endif

return
*	09/sep/2001 pdv	Created. Inspired by code from the Hacker's Guide.
*	24/mar/2002 pdv Improved.
*	10/apr/2005 pdv Improved.

*	Will shutdown ALL In-Screen and In-Top-Level forms.
*	Will also shutdown As-Top-Level forms if you pass True.

*	Will return True if the shutdown was successful, else False. False implies 
*	that a form's QueryUnload() returned False.

PROCEDURE ShutDownForms
lparameter tlAlsoToplevelForms

local llShutDownOK, lnCnt

llShutDownOK = .t.

for lnCnt = _screen.formcount to 1 step -1	&& Backward safer, for the array will shrink with each removal.
	*
	if m.lnCnt <= _screen.formcount			&& It may be that one form's close also closed one or more other forms.
		*			
		if _screen.forms[ m.lnCnt ].baseclass = "Form" ; 		&& skip toolbars
		and _screen.forms[ m.lnCnt ].showwindow # 2			&& for now, preserve toplevel form
			*
			if _screen.forms[ m.lnCnt ].queryunload()
				*
				if m.lnCnt <= _screen.formcount			&& It may be that the queryunload() also released the form.
					_screen.forms[ m.lnCnt ].release()
				endif
			else
				llShutDownOK = .f.
				exit
			endif
		endif
	endif
endfor

if m.llShutDownOK and m.tlAlsoToplevelForms

	for lnCnt = _screen.formcount to 1 step -1	&& Backward safer, for the array will shrink with each removal.
		*
		if m.lnCnt <= _screen.formcount			&& It may be that one form's close also closed one or more other forms.
			*			
			if _screen.forms[ m.lnCnt ].baseclass = "Form" ;
			and _screen.forms[ m.lnCnt ].showwindow = 2		&& now remove toplevel form
				*
				if _screen.forms[ m.lnCnt ].queryunload()
					*
					if m.lnCnt <= _screen.formcount			&& It may be that the queryunload() also released the form.
						_screen.forms[ m.lnCnt ].release()
					endif
				else
					llShutDownOK = .f.
					exit
				endif
			endif
		endif
	endfor
endif

RETURN m.llShutDownOK
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform