Kill all windows except menu

PatrickTingen

New Member
We have an application that is a mix of ADM-1 (yes, ADM one) and non-adm windows on OE11.2. We want to add some functionality that allows the user to jump back to the main menu, regardless of where they are in the application.

We would like to solve this in a generic way. We already experimented a bit; in our main menu program we do a PUBLISH 'goBackToMenu'. We modified the ADM toolbar so that it subscribes to that event. When it is fired, the toolbar checks whether the screen is in update state. If not, it closes it. Control is now back to the main menu program where we start the requested program.

The problem is that windows without a toolbar obviously do not respond to this.
We could modify all non-toolbar windows to add code to respond to the event, but it would be nice if this could be done more generic.

We tried to do something along these lines:

Code:
DEFINE VARIABLE i AS INTEGER NO-UNDO.

REPEAT:
  i = i + 1.
  IF PROGRAM-NAME(i) = 'main-menu.w' THEN LEAVE.
  DELETE OBJECT VALUE( PROGRAM-NAME(i) ).
END.

But there is no way to kill all windows that were started from the main man

Any ideas?
 
Would something using hProc = session:first-procedure and hProc = hProc:next-sibling, filtering on the hProc:file-name, then DELETE PROCEDURE hProc when it matches, work?
 

PatrickTingen

New Member
Something like this?

Code:
DEFINE VARIABLE hWin  AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.

hWin = SESSION:FIRST-PROCEDURE.
REPEAT:
  IF hWin:NAME = 'alg\menu.w' THEN RETURN.
  hProc = hWin.
  hWin = hWin:NEXT-SIBLING.
  DELETE OBJECT hProc NO-ERROR.
  IF NOT VALID-HANDLE(hWin) THEN RETURN ?.
END.

It destroys all my supers, then messes with the elements on the window that is currently open, making browses and viewers suddenly empty. Then leaves the window floating.
 
Well almost there ;)

If you can identify all your windows, e.g. if they are in their own directory, let's say "mywin", I'd go with something like (not tested):

Code:
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
DEFINE VARIABLE hNextProc AS HANDLE NO-UNDO.

hProc = SESSION:FIRST-PROCEDURE.
hNextProc = hProc:NEXT-SIBLING NO-ERROR.
REPEAT:
  IF hProc:FILE-NAME MATCHES "*/mywin/*" AND NOT hProc:FILE-NAME MATCHES "*alg\menu.w" AND hProc:TYPE = "WINDOW" THEN DO:
    DELETE PROCEDURE hProc NO-ERROR. /* or APPLY "CLOSE" TO hProc. ??? */
    hProc = hNextProc. /* that's why I introduce hNextProc: if you DELETE hProc, you cannot do :NEXT-SIBLING on it ;= */
  END.
  hProc = hProc:NEXT-SIBLING NO-ERROR.
  hNextProc = hProc:NEXT-SIBLING NO-ERROR.
  IF NOT VALID-HANDLE(hProc) THEN LEAVE.
END.
 
Top