How can I, from a stored procedure, close all windows in my applicaton, including any open popups and messages, except for my application startup window and one other "home page" window? In other words, I want to close every open window and return to a "home page" form.
Mark Glicksman
Glenside, PA
Mark,
One way is to use the Utility("OBJECTLIST") function to get the list of running OpenInsight windows. You can then loop through this and send a CLOSE event or do a Utility("DESTROY"). The former takes into consideration unsaved changes while the latter is unconditional.
dbakke@srpcs.com
Bingo! Objectlist works. Thanks.
Mark Glicksman
Glenside, PA
Don,
Just a detail. Is there something special you must do with e.g modal windows? Must you close them before their parents? In general - are there cases where order is important?
- Oystein -
Oystein,
Interesting question. The only way I've ever implemented this is in the CLOSE event of a main application window so I've never had to deal with modal windows running. My hunch is that with Utility("DESTROY") you don't have to worry (because of parent child relationships) but sending a CLOSE event would require you to deal with the modal windows first.
dbakke@srpcs.com
Well, I have had problems closing modal windows - messages and some popups (other popups close with no trouble). I have tried destroy, send_event close, and end_window, with the same results. So, I'm now looking at the code associated with each modal window more closely. I'll let you know what I find.
glicks@compuserve.com
Mark,
From reading about Utility("DESTROY") it appears that it may be prevented from completing it's task if the WM_CLOSE message (i.e. the CLOSE event) prevents this from happening (e.g. Returns 0 instead of 1). But this is just a guess.
Alternatively, I think you can call the Windows API command DestroyWindow() directly. It may be able to be halted as well however. I haven't tried this so use at your own risk!
dbakke@srpcs.com
I've go my close all windows routine to work perfectly. There were a few "modal" statements in my code that shouldn't have been there, when I got rid of them - no problem closing modal windows. Here's what I used:
Declare Function Send_Event, Utility
AllWindows=Utility('OBJECTLIST', '', 'WINDOW')
I =1
WindowName=AllWindows[i]
Loop Until WindowName="
Begin CaseCase WindowName=VQF_HOME"Case WindowName=MAINMENU"Case 1Retval=Send_Event(WindowName, "CLOSE")End CaseI += 1WindowName=AllWindows[i]Repeat
glicks@compuserve.com