Using Intel® Visual Fortran to Create and Build Windows*-Based Applications

ID 757211
Date 7/23/2021
Document Table of Contents

Setting Return Values and Exiting

When the user selects the dialog's OK or CANCEL button, your dialog procedure is exited and the dialog box is closed. DLGMODAL returns the control name (associated with an integer identifier in your include (.FD) file) of the control that caused it to exit; for example, IDOK or IDCANCEL.

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 DLGEXIT from within your callback routine. For example:

SUBROUTINE EXITSUB (dlg, exit_button_id, callbacktype)
INTEGER exit_button_id, callbacktype

The only argument for DLGEXIT is the dialog derived type. The dialog box is exited after DLGEXIT returns control back to the dialog manager, not immediately after calling DLGEXIT. That is, if there are other statements following DLGEXIT 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 DLGMODAL to return with a value other than the control name of the control that caused the exit, (or -1 if DLGMODAL fails to open the dialog box), you can specify your own return value with the subroutine DLGSETRETURN. For example:

INTEGER altreturn
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 DLGSETSUB 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 IDCANCEL. When a system escape or close is performed, it simulates pressing the dialog button with the ID IDCANCEL. If no control in the dialog has the ID IDCANCEL, 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 IDCANCEL 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.

Did you find the information on this page useful?

Characters remaining:

Feedback Message