Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to close all forms?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00284684
Message ID:
00284742
Views:
26
Hi John,

The _screen.forms is a collection and is LIFO (last in / first out). What's happening is the foreach moves down through the collection closing forms as it goes, but each time a form is closed, all the remaining forms move up in the collection. Also, the forms collection will contain any toolbars so you need to trap for them.

This should work: (This calls the Queryunload method and only releases the form if it returns .T.
nFormIndex = 1
FOR x = 1 TO _SCREEN.FORMCOUNT
	oForm = _SCREEN.FORMS[ nFormIndex ]
	IF oForm.BASECLASS $ 'Toolbar'
		nFormIndex = nFormIndex + 1
	ELSE
		** We've got only forms now.
		IF oForm.QUERYUNLOAD()
			oForm.RELEASE()
		ELSE
			nFormIndex = nFormIndex + 1
		ENDIF
	ENDIF
ENDFOR
hth


>Hi,
> I have a top level form.All of my data entry form are MDI form which will be active in Top level form. How could I close all active form in my top level? I use the following code, but it doesn't close all....
>
>

>FOR EACH loform IN _SCREEN.FORMS
> IF .not. loForm.NAME = mytoplevel.NAME
> loform.release
> ENDIF
>NEXT
>
>Anything goes wrong?
>
>Thank you
Roi
'MCP' Visual FoxPro

In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform