>>Thank you for your input. As I wrote in my message to Dragan, the code above will work in majority of the cases. But since I will include it in a TRY/CATCH, there could be a time when the code will not run. And in this case, the application will try to close with some forms being open.
>>I will test a case with a messagebox() window being open and at the same time trying to close the application.
>
>Messagebox is nearly not solvable. As long as you don't use a custom one, you might issue KEYBOARD '{ESC}' or the like to close a messagbox. Reportpreview there is control, if you use BEHAVIOUR 90. Else there is only KEYBOARD, and the form calling the report needs to know.
>
>I do something like setting a flag to my form telling the form that a child window is open, an then it runs through its form manager trying to close the child form first and deny it's own shut down. Job of QUERYUNLOAD. This needs a timer on application level so it try to shutdown several time. (One must first end all code where, for example, a modal window is involved, then the form.) Complex crap I lost a month till it was working.
During my testing, I find that the messagebox() is not the worst of the possible problems.
I have one big window (modeless) that references a Public object oPassword, in one of the control methods.
So, when I try close the application, while this window is still open, I get an error that "oPassword is not defined". Which tells me that the object oPassword is destroyed and then the application tries to self-close this window.
The conclusion is that the code, above, that closes all open windows, IS important.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham