>I need a way to detect whether a given form is currently in use or even better to generate a list of open forms.
YOu can use _screen.Forms and Sys(1271) like Cetin said, but this is why most people create their own FOrms Manager. You might want to try something like that.
>Second, I want to be able to do a cleanup procedure when the application is closed. This procedure would close all open forms and notify the user is there is any trouble closing any of the forms.
I put this code in the QueryUnload event of the forms. Add a NODEFAULT and a RETURN .F. if the form can't be closed at the current time. NODEFAULT is required by VFP to prevent closing a form with the "X" button. RETURN .F. is so you can do something like this:
llContinue = .T.
for lnI = _screen.formcount to 1 step -1
if _screen.Forms[lnI].QueryUnload()
_screen.Forms[lnI].Release()
else
llCOntinue = .F.
exit
endif
endfor
ANd then check the value of llCOntinue to see if the was a problem or not.