View previous topic :: View next topic |
Author |
Message |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Tue Jul 24, 2012 9:43 am Post subject: Close all windows and terminate |
|
|
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 |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Tue Jul 24, 2012 10:38 am Post subject: |
|
|
Hi Eric,
a return value of zero will close the window. Try for instance something like this:
Code: | 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 |
|
Back to top |
|
|
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Tue Jul 24, 2012 2:07 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Jul 25, 2012 10:43 am Post subject: |
|
|
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 |
|
Back to top |
|
|
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Wed Jul 25, 2012 2:01 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Thu Jul 26, 2012 6:30 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Fri Jul 27, 2012 2:23 pm Post subject: |
|
|
At the moment I've settled for 'Save & Exit' |
|
Back to top |
|
|
|