Silverfrost Forums

Welcome to our forums

Close all windows and terminate

24 Jul 2012 8:43 #10504

Hallo from Perth, Western Australia 😄

The parent window is open, and also open is one child window. Is there a 'button' I can install on the child window which, when clicked, will close ALL windows and terminate the program? A sort-of ClearWin crash-dive 😃

Eric

24 Jul 2012 9:38 #10505

Hi Eric,

a return value of zero will close the window. Try for instance something like this:

      winapp

      program test

      INCLUDE <WINDOWS.INS>

      external    AAA
      integer*4   j,flag

      common  /win_handle/  flag

      flag = 1

      j = winio@('%ca[Test]%mn[Next window,Exit]',AAA,'EXIT')
      end

cccccc==================================================================ccc

      integer function AAA()

      INCLUDE <WINDOWS.INS>

      external       close_all
      integer*4      j,flag

      common  /win_handle/  flag

      j = winio@('%ca[Child window]%ff%nlchild window%ff%nl&')
      j = winio@('%cn%^bt[Close this window]&','EXIT')
      j = winio@('%^bt[Close all windows]',close_all)

      AAA = flag   ! if flag = 0, all windows will be closed
      end

cccccc==================================================================ccc

      integer function close_all()

      integer*4      flag
      common  /win_handle/  flag

      flag = 0
      close_all = 0
      end

Regards - Wilfried

24 Jul 2012 1:07 #10506

Clicking on the [Close all windows] button invokes the close_all function which returns with a zero value which closes the child window, AAA.

But, unbeknown to the child, it now returns a zero value to its parent, courtesy of flag being set to zero by close_all. Horrified, entire family now disappear into the Big Bit Bin in the Sky!

No wonder we learn to distrust our offspring 😄

The elegance of the algorithm rather mitigates its gruesomeness 😄 Thank you for making the effort to respond, Wilfried. It is much appreciated 😄

25 Jul 2012 9:43 #10508

Eric and Wilfried,

It is OK if the big red button resides in the ultimate child window. Then one can cascade back all the way up the list to the ultimate ancestor, closing as you go with zero return codes

If the big red button is in the ultimate ancestor window, then getting the descendants to close is a slightly more difficult problem.

The use of %lw[owned] suggests itself here, (along with other varieties of %lw to give a simple closure control) or by having the forethought to get each windows handle using %hw so that the decendants are all terminated by an explicit close window call DestroyWindow (in the GUI).

If you don't have the handles, you are into more complex territory ...

Eddie

25 Jul 2012 1:01 #10509

G'day, Eddie!

Wonderful to hear from you 😄

Many thanks for the elaboration regarding handles. It'll come in handy if the Big Red Button has to migrate.

We're wondering what to label the Button. 'Apocalypse' has been suggested 😄

Eric

26 Jul 2012 5:30 #10517

I suggest Kronos for the label on a button that devours its children, and maybe Oedipus for one that assassinates its parent (but only one!).

Defenestrate sounds that it could have the right meaning, but although one or two folks have tried to redefine it as ridding oneself of Windows (as in installing Linux), it really means to chuck someone out of a window!

Shut up shop? Curtains (I like the dual meaning) ?

The big red button iconography is probably best, as a picture is worth a 1000 words ...

Eddie

27 Jul 2012 1:23 #10519

At the moment I've settled for 'Save & Exit' 😄

Please login to reply.