>Hi,
>
>I wrote (or copied it from somewhere) the code below 10 years ago. And now I don't remember it's purpose. This code is called from the method, right after the READ EVENTS, when application is being closed.
>What is the purpose of closing all forms when a user wants to close the application?
>I tried to comment this code and only issue ON SHUTDOWN, after READ EVENTS, and I get no error when some forms are still open. The ON SHUTDOWN seem to close these forms anyways.
>
>
> LOCAL lnForms, i, llDone
> lnForms = _screen.formcount
> FOR i = lnForms to 1 STEP -1
>
> IF TYPE("_SCREEN.Forms(i)") <> "O" OR ISNULL( _SCREEN.Forms(i) )
> LOOP
> ENDIF
>
> IF PEMSTATUS(_SCREEN.Forms(i), 'QueryUnload', 5)
> llDone = _SCREEN.Forms(i).QueryUnload()
> IF !llDone
> RETURN .F.
> ENDIF
> ENDIF
> _screen.Forms(i).Release
> ENDFOR
>
>
>Thank you in advance for any input
If you have a modal form open or a report preview, or a messagebox, this could all be fun. If the forms (objects) get's closed the wrong order you might "close" a form with code waiting for a modal form. The modal one close second, proceeds with the code and you got a lot of strange errors, because THIS and THISFORM, open tables etc the code is expecting are gone. For a long time I even disabled ALT+F4 (ON SHUTDOWN *) etc at all. Now I do a lot of loops and checks to have the forms shutting down in the right order. This might be complex.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]