WoConfirmClose Procedure
Displays a dialog box requiring the user to confirm a window close action.
Usage
WoConfirmClose, wid, tool_name
Input Parameters
wid — (long) Specifies the widget ID of the parent of the dialog box.
tool_name — (string) Specifies the unique name of the VDA Tool to close.
Input Keywords
NoUnRegister — If nonzero, the VDA Tool is not automatically unregistered.
Output Keywords
Status — Returns the status of the user interaction: If 0, then the user cancelled the close operation; if 1, the user confirmed the close operation.
Discussion
If the user’s response is to close the VDA Tool, TmUnregister is called to close the specified VDA Tool.
This routine is registered with the ConfirmClose keyword of the WwInit and WwMainWindow functions. It is used when the Close command on the Window Manager menu is selected. This routine is also used by the File menu’s Exit command in VDA Tools.
WoConfirmClose checks the confirmClose resource to determine whether or not to display the confirmation dialog box. If this resource is set to FALSE, the TmUnregister procedure is called without asking the user to confirm the close.
Example 1
The following command is taken from the code for the WzColorEdit VDA Tool. Here, WoConfirmClose is called as a keyword to the WwMainWindow function.
...
top = WwMainWindow (parent, layout, 'WoDestroyCB', $
Shell_name = 'WzColorEdit', Layout_name = 'toolArea', $
ConfirmClose = 'WoConfirmClose', Title = unique_name, $
/Form, Userdata = unique_name)
...
Example 2
The NoUnRegister and Status keywords are primarily used by the Navigator. These keywords allow the Navigator to systematically unregister VDA Tools when the Navigator is unregistered.
PRO NavCloseCB, wid, index
; Forward declaration of TM functions.
DECLARE FUNC, TmEnumerateToolNames
DECLARE FUNC, TmGetTop
top = TmGetTop('Navigator')
; Make sure the user wants to quit.
WoConfirmClose, top, 'Navigator', Status=status, $
/NoUnRegister
; If answer affirmative, close all tools, ending with Nav.
IF status EQ 1 THEN BEGIN
all_tools = TmEnumerateToolNames()
FOR i=0L, N_ELEMENTS(all_tools)-1 DO BEGIN
IF all_tools(i) NE 'Navigator' $
THEN TmUnregister, all_tools(i)
ENDFOR
; Finish with the Navigator closed.
TmUnregister, 'Navigator'
ENDIF
END
See Also