When the user selects the dialog's OK or CANCEL button, your dialog procedure is exited and the dialog box is closed.
returns the control name (associated with an integer identifier in your include (.FD) file) of the control that caused it to exit; for example,
If you want to exit your dialog box on a condition other than the user selecting the OK or CANCEL button, you need to include a call to the dialog subroutine
from within your callback routine. For example:
SUBROUTINE EXITSUB (dlg, exit_button_id, callbacktype)
TYPE (DIALOG) dlg
INTEGER exit_button_id, callbacktype
CALL DLGEXIT (dlg)
The only argument for
is the dialog
derived type. The dialog box is exited after
returns control back to the dialog manager, not immediately after calling
. That is, if there are other statements following
within the callback routine that contains it, those statements are executed and the callback routine returns before the dialog box is exited.
If you want
to return with a value other than the control name of the control that caused the exit, (or -1 if
fails to open the dialog box), you can specify your own return value with the subroutine
. For example:
TYPE (DIALOG) dlg
altreturn = 485
CALL DLGSETRETURN (dlg, altreturn)
To avoid confusion with the default failure condition, use return values other than -1.
It is not possible to return a value when a modeless dialog box exits. However, you can call
to set the DLG_INIT callback routine to have a procedure called immediately before the dialog box is destroyed.
If you want the user to be able to close the dialog from the system menu or by pressing the ESC key, you need a control that has the ID of
. When a system escape or close is performed, it simulates pressing the dialog button with the ID
. If no control in the dialog has the ID
, then the close command will be ignored (and the dialog can not be closed in this way).
If you want to enable system close or ESC to close a dialog, but do not want a cancel button, you can add a button with the ID
to your dialog and then remove the visible property in the button's Properties Window . Pressing ESC will then activate the default click callback of the cancel button and close the dialog.