Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question about CloseAllForms method in Forms manager
Message
 
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01102443
Message ID:
01102566
Views:
18
This message has been marked as the solution to the initial question of the thread.
Well, I went ahead and made a change in cManagers (since we've made bunch of framework changes already) to always start from the ActiveForm.
*---------------------- Location Section ------------------------
*   Library: CManager.vcx
*   Class:   CFormMgr
*   Method:  CloseAllForms()
*----------------------- Usage Section --------------------------
*)  Description:
*)		Closes all application forms
*   Scope:      Public
*   Parameters:
*		1. tlForceShutDown - If true, close all forms without
*			running QueryUnload first.
*
*$  Usage:      goApp.oForms.CloseAllForms()
*$
*   Returns:  Logical .T. if all forms were closed, otherwise .F.
*--------------------- Maintenance Section ----------------------
*   Change Log:
*	Created:  11/12/97 - KJM
*	MODIFIED: 03/24/98 - KJM
*		Rather than referencing the form to be closed as
*		"_SCREEN.Forms(lnFormToClose)" throughout the method,
*		saved a reference to the form in loForm. This was
*		necessary because the call to loForm.QueryUnload()
*		may launch a MsgSvc form that changes the _SCREEN.Forms
*		collection.
*	MODIFIED: 01/20/99 - KJM
*		Added a check for:
*		NOT ISNULL(_SCREEN.Forms(lnFormToClose)
*	MODIFIED: 04/15/99 - KJM
*		Added the tlForceShutDown parameter. If set to True,
*		close forms without running "QueryUnload()" first.
*	MODIFIED	07/06/99 - KJM
*		Changed this method to close forms in reverse order.
*	MODIFIED	09/29/99 - KJM
*		Moved the code that releases the Sidebar form to the
*		bottom of the method so it releases last. Also added
*		a check in the FOR loop so the sidebar is not released.
*	MODIFIED	10/04/99 - KJM
*		If not in "force shutdown" mode, set the active form's
*		lWriteBuffer property to .T.
*	MODIFIED	08/31/00 - KJM
*		Rather than setting the SideBarForm to .NULL., released
*		it instead.
*  MODIFIED 11/04/05 - NN - added check for loForm as object
*  MODIFIED 03/08/06 - NN - made sure to start with the currently active form first
*****************************************************************
LPARAMETERS tlForceShutDown
LOCAL lnForm, lnFormToClose, loForm, lnFormCount

IF NOT m.tlForceShutDown
	THIS.SetActiveFormWriteBuffer(.T.)
*-- CHANGE - NN - March 08, 2006 - 13:40:50 - added the code bellow
	IF TYPE("_SCREEN.ActiveForm.name") = "C"
		loForm = _SCREEN.ACTIVEFORM

		IF m.loForm.QUERYUNLOAD()
*--------------------
*--- Release the form
*--------------------
*-- CHANGE - NN - November 04, 2005 - 13:19:21
			IF VARTYPE(m.loForm) = "O"
				m.loForm.RELEASE()
			ENDIF
		ELSE
			_SCREEN.MOUSEPOINTER = MOUSE_DEFAULT
			RETURN .F.
		ENDIF
	ENDIF
ENDIF

*--------------------------------------------------------------
*-- Loop through all open forms and request that they be closed
*--------------------------------------------------------------
lnFormCount = _SCREEN.FORMCOUNT

FOR lnFormToClose = m.lnFormCount TO 1 STEP -1

	IF TYPE("_SCREEN.Forms(lnFormToClose)") == "O" ;
			AND NOT ISNULL(_SCREEN.FORMS(m.lnFormToClose))

		loForm = _SCREEN.FORMS(m.lnFormToClose)

		IF "TOOLBAR" == UPPER(m.loForm.BASECLASS)
			LOOP
		ENDIF

		IF VARTYPE(THIS.oSideBarForm) == 'O' AND ;
				COMPOBJ(m.loForm, THIS.oSideBarForm)
			LOOP
		ENDIF

		IF m.tlForceShutDown
			m.loForm.RELEASE()
		ELSE
*------------------------------
*--- Run the form's QueryUnload
*------------------------------
			IF m.loForm.QUERYUNLOAD()
*--------------------
*--- Release the form
*--------------------
*-- CHANGE - NN - November 04, 2005 - 13:19:21
				IF VARTYPE(m.loForm) = "O"
					m.loForm.RELEASE()
				ENDIF

			ELSE
				_SCREEN.MOUSEPOINTER = MOUSE_DEFAULT
				RETURN .F.
			ENDIF
		ENDIF

	ENDIF
ENDFOR

IF VARTYPE(THIS.oSideBarForm) == "O"
	THIS.oSideBarForm.RELEASE()
ENDIF
>Hi everybody,
>
>The user pointed out to a problem. When you close the application using Exit button on the main toolbar, but reply Cancel on the question: Do you want to Save changes? (e.g. change your mind and want to continue editting), some of the forms are already closed. In other words, it looks like we need to always close the forms starting with the ActiveForm.
>
>Did anyone encounter this problem? Have you changed Form's manager?
>
>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform