|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Jan 17, 2007 9:48 pm Post subject: Windows that won't die on exiting an application. |
|
|
My programming "labour of love" at the moment has a main window that never closes (%lw) and which contains a large %gr graphics region. Other windows may be called into existence to do various things, all of which have an effect on the %gr. I found recently that a bloody-minded user could close the main window by using the close "X" on the top-right of the caption bar. This left any active subsidiary window sulking sullenly in Windows, not showing its %mi icon. I only discovered this by chance because a recompile and relink couldn't generate the .EXE file.
The answer to the sulky windows was to examine the return code to SELECT_GRAPHICS_OBJECT@ which I call (before writing to the %gr) to see if the %gr is still there, and if it isn't, to arrange some return mechanism to ensure that the sulky window went away.
Before I discovered this, however, I was experimenting with %cc in the main window. The standard callback 'EXIT' wasn't what I wanted, as there was no second chance - there was with 'CONFIRM_EXIT'. Of course, you don't want two 'CONFIRM_EXIT's in any program, as they generate a sense of deja vu (double confirmations required), but an 'EXIT' elsewhere gracefully invokes the 'CONFIRM_EXIT' associated with %cc, which is neat. However, both the standard callbacks leave those sulky windows lurking.
To my surprise, when I wrote my own callback function, a Fortran STOP also leaves the sulky windows. I was always of the opinion that STOP was a "kill-all" command. I recall on an IBM 1130 it would physically stop the machine, so we had to CALL EXIT instead. I noticed in the topic by Sparge that he uses EXIT as a Fortran command, and on searching in the Help file, found EXIT@ and ABORT@ as well.
What is the preferred method of making sure that one's program is well and truly dead when you decide to kill it? This information could usefully be collected into one place in the Help file.
Eddie |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Thu Jan 18, 2007 1:28 pm Post subject: |
|
|
Hi Eddie,
Firstly it is unfair to expect a STOP to kill all the windows, since Clearwin is not part of standard fortran. Write a console program with no windows and sure STOP kills the program execution.
I have an application with similar graphics and dialog window boxes to you, with at least one graphics and one text window always open. I use %cc in both of these windows to call my own callback function. This call back then simply closes all the seperate windows down before encountering the STOP statement.
I hope this helps.
John |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Thu Jan 18, 2007 10:27 pm Post subject: |
|
|
Hi John,
Given my experience (back in 1970) that STOP could be a powerful agent, it was my first recourse.
Of course the Clearwin callbacks 'EXIT' and 'CONFIRM_EXIT' are part of Clearwin, and they do the same as STOP. Presumably the Clearwin team discovered that a small nuke wasn't enough, so designed a bigger one (ABORT@).
What do you do - get the window handle(s) with %hw and use DESTROY_WINDOW@ on each one? Or is there a better way?
Eddie |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Fri Jan 19, 2007 12:32 am Post subject: |
|
|
Hi Eddie,
I dug into my code and extracted the following lines:-
last two lines of the text window winio:-
i=winio@('%cc&',CLOSE_WINDOW_TRAP)
i=winio@('%pv%60.20cw[vscroll,hscroll]%bg[grey]%hw%lw',
*6,iconsole,iwrite6)
last part of of the graphics window winio:-
i=winio@('%cc&',CLOSE_WINDOW_TRAP)
i=winio@('%hw%lw',ictrl_api,ictrl)
According to user preference settings, the close_window_trap will either:-
1). Ignore the window closure request.
2). Ask for confirmation before closing down.
3). Immediately close down all windows and halt the program.
The windows are closed by the following lines
IWRITE6=0
call window_update@(IWRITE6)
ICTRL=0
call window_update@(ICTRL)
So as you can see it is the control variable using %lw that kills the windows.
cheers
John |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|