Message
General information
Fórum:
Visual FoxPro
Category:
Programação, sintaxe e comandos
Miscellaneous
ID da thread:
00359746
ID da mensagem:
00359758
Views:
22
>>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
Or, if there is no code in QueryUnload it can be just like this:

ln = _screen.formcount
FOR i = ln to 1 STEP -1
_screen.Forms(i).Release
ENDFOR
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Responder
Mapa
View