Sylvain,
I suspect it might be a timing issue and the WITH. It is basically holding a reference to the form. You might try fully qualified references instead:
if ( _screen.ActiveForm.QueryUnload() )
_screen.ActiveForm.Release()
else
If that doesn't work maybe try _screen.Forms[] collection instead.
>Could someone please explain why this code work inside VFP and not from a EXE?
>
>This code is from the File|Exit menu to close all open forms before quitting the application. For a reason I can't catch, it will loop indefinitly, refusing to release the form. There's no message and the Release() method is called (I placed a WAIT WINDOW inside the IF to check it).
>
>I'm using VFP 5.0
>
>
llExitOK = .T.
>
>DO WHILE llExitOK AND (Type("_Screen.ActiveForm") = "O")
> WITH _Screen.ActiveForm
> IF .QueryUnload()
> .Release()
> ELSE
> llExitOK = .F.
> ENDIF
> ENDWITH
>ENDDO
>
>TIA