if program( program(-1) - 1 ) # 'SHUTDOWNFORMS' * do downshut endif
PROCEDURE DownShut if ShutDownForms( .T. ) * release popups release menus * on shutdown clear events endif return
* 09/sep/2001 pdv Created. Inspired by code from the Hacker's Guide. * 24/mar/2002 pdv Improved. * 10/apr/2005 pdv Improved. * Will shutdown ALL In-Screen and In-Top-Level forms. * Will also shutdown As-Top-Level forms if you pass True. * Will return True if the shutdown was successful, else False. False implies * that a form's QueryUnload() returned False. PROCEDURE ShutDownForms lparameter tlAlsoToplevelForms local llShutDownOK, lnCnt llShutDownOK = .t. for lnCnt = _screen.formcount to 1 step -1 && Backward safer, for the array will shrink with each removal. * if m.lnCnt <= _screen.formcount && It may be that one form's close also closed one or more other forms. * if _screen.forms[ m.lnCnt ].baseclass = "Form" ; && skip toolbars and _screen.forms[ m.lnCnt ].showwindow # 2 && for now, preserve toplevel form * if _screen.forms[ m.lnCnt ].queryunload() * if m.lnCnt <= _screen.formcount && It may be that the queryunload() also released the form. _screen.forms[ m.lnCnt ].release() endif else llShutDownOK = .f. exit endif endif endif endfor if m.llShutDownOK and m.tlAlsoToplevelForms for lnCnt = _screen.formcount to 1 step -1 && Backward safer, for the array will shrink with each removal. * if m.lnCnt <= _screen.formcount && It may be that one form's close also closed one or more other forms. * if _screen.forms[ m.lnCnt ].baseclass = "Form" ; and _screen.forms[ m.lnCnt ].showwindow = 2 && now remove toplevel form * if _screen.forms[ m.lnCnt ].queryunload() * if m.lnCnt <= _screen.formcount && It may be that the queryunload() also released the form. _screen.forms[ m.lnCnt ].release() endif else llShutDownOK = .f. exit endif endif endif endfor endif RETURN m.llShutDownOK