Hi Dan,
I stumbled over this too. The answer is that 'Exit' is for a REALLY quick hack, and 'Confirm_Exit' is for a nearly as quick hack. For real work, you have to do it yourself.
The problem is that there are several ways to close a window, including the File / Exit route, the close box on the window, Exit Windows, Alt-F4 etc. They can't all be 'Exit'. If in addition you use %cc, you have to think carefully or you get asked twice, or not at all, whether you want to save the file befoe exitting.
I do this in the main window:
IA = WINIO@('%cc&', EndExit_FUNCTION)
IA = WINIO@('%ew&', EndExit_FUNCTION)
IA = WINIO@('%mn[[|,E&xit]]&', EndExit_FUNCTION)
The End_Exit function looks like this:
INTEGER FUNCTION EndExit_FUNCTION()
C -----------------------------------
C
C call back function for CLOSE. Clears graphics area, and re-sets
C permission to OPEN file or have NEW file
C
C -----------------------------------------------------------------
INCLUDE <WINDOWS.INS>
EXTERNAL File_FUNCTION
COMMON/GREYS/ IGR(10),JGR(10),KGR(10),LGR(10),MGR(10),NGR(10)
C .
CHARACTER*(129) FILENM
COMMON /FILES/ FILENM
CHARACTER*(129) PATH(4)
COMMON/PATHS/ PATH
CHARACTER*(20) FLTN(2), FLTS(2), CAPT
SAVE
INTEGER File_FUNCTION
COMMON/EXITCODE/ INHIBIT_EXIT
C ... second pass through this function? Always quit.
EndExit_FUNCTION = 1
IF (INHIBIT_EXIT .EQ. 0) THEN
EndExit_FUNCTION = 0
RETURN
ENDIF
C ... anything worth saving? I this case give option to save.
IF (MGR(3) .NE. 0 .OR. MGR(4) .NE. 0) THEN
IA=WINIO@('%ca[Quit using Program]&')
IA=WINIO@('%si? Do you want to save your data first? &')
IA=WINIO@('%ff%nl%cn%6`bt[Yes] %6bt[No] %6bt[Cancel]')
C ... Cancelled or Close box - return, keeping main window open
IF (IA .EQ. 0 .OR. IA .EQ. 3) RETURN
C ... Don't save. In this case go on to exit. Be aware that this
C could lead to a second pass through this callback function
IF (IA. EQ. 2) THEN
EndExit_FUNCTION = 0
RETURN
ENDIF
C ... Save file - at least, give the option to save. User can still
C decide not to save. This can't be done with callback on the
C button. Be aware that this
C could lead to a second pass through this callback function
IF (IA .EQ. 1) THEN
CAPT = 'File to save to'
FLTN(1) = 'WSX files'
FLTN(1) = 'All files'
FLTS(1) = '*.wsx'
FLTS(2) = '*.*'
CALL GET_FILTERED_FILE@ (CAPT,FILEnm,PATH(1),FLTN,FLTS,2,0)
CALL CORRECT_NAME(FILEnm,'.wsx')
IJ = File_FUNCTION() ! This is in this file
INHIBIT_EXIT = 0
ENDIF
EndExit_FUNCTION = 0
C ... If the user closes a window without a current file, we need
C to close the main window. Just in case this leads to a second
C pass, then set INHIBIT_EXIT to 0 (no), although it will be
C caught here the second time round. INHIBIT_EXIT is cleaner.
ELSE ! This is ELSE to the IF about MGR 3 and 4.
INHIBIT_EXIT = 0
EndExit_FUNCTION = 0
ENDIF
RETURN
END
In the context of my program, you can only save if MGR(3) or (4) is set appropriately - and these are also grey-out codes for something or other, probably saying that SAVE and SAVE_AS are available. File_FUNCTION contains the Fortran writes to actually save the file. Inhibit_Exit is set to 1 when a datafile is created or opened. I have afeeling that the above has 'belt and braces' code in it - I make no claims that it is either elegant or foolproof!
You may have to program more to have an 'Are you sure?' - but then how many chances do you give the user?
Eddie