Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global error handler question - one more try
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00399020
Message ID:
00399347
Views:
20
>>>for x = 1 to _screen.formcount
>>> if type("_screen.ActiveForm")#"O" or ;
>>> isnull(_screen.activeform)
>>> loop
>>> endif
>>> _screen.activeform.release
>>>endfor
>
>Nadya,
>
>The reason this loop works is x is not used as a reference so you start with the number of active forms and release them all or loop. IOW, if formcount = 3 release the active form 3 times. BTW, I only use this when about to exit, otherwise I use the forms collection in my app.


Hi Erik,

I agree. In the meanwhile I was searching for the thread about closing forms properly. I typed 'Closing forms' in Search and it have me >900 messages. Anyway, this thread should bring some light on this problem:
Coding, syntax & commands Re: Program to close all forms Thread #359746 Message #359752
From 14/04/2000 09:06:10
George Tasker #011537
Shaw Ind.
Cartersville, Georgia
To 14/04/2000 08:45:24
Jerry Tovar #012505
Dana - Drivetrain Service Division
Holland, Ohio

>I am trying to run a program to close all forms on the screen. However, the following code closes all but the last form.
>
>***
>FOR EACH oform IN _screen.forms
> oform.RELEASE()
>ENDFOR
>***
>
>How can I get all the opened forms to close?
>
>Thanks,
>
Jerryt,

You need to do it backwards through the collection. If the forms use the QueryUnload method to check to make sure the form can release, you'd need to check the results of that as well:
lnforms = _SCREEN.FormCount
lldone = .T.
DO WHILE lnforms > 0 AND lldone
lldone = _SCREEN.Form(lnforms).QueryUnload()
IF lldone
_SCREEN.Form(lnforms).Release
lnforms = lnforms - 1
ENDIF
ENDDO
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