CDialog::EndDialog

Syntax

void EndDialog( int nResult );

Parameters

nResult

Contains the value to be returned from the dialog box to the member function that created it.

Remarks

Used for modal dialog boxes. Modeless dialogs do not use this member function.

The EndDialog member function terminates a modal dialog box and returns the given result to the function that created the dialog box. The EndDialog function is required to complete processing whenever a modal dialog box is created and may not be used for any other purpose.

The dialog function can call EndDialog at any time, even during the processing of the WM_INITDIALOG message in OnInitDialog. If called during processing of the WM_INITDIALOG message, the dialog box is terminated before it is shown or before the input focus is set.

EndDialog does not close the dialog box immediately. Instead, it sets a flag that directs the dialog box to close as soon as the standard Foundation dialog-box function (AfxDlgProc) ends. The EndDialog function returns to the dialog-box function, so it must return control to Windows.

See Also

CModalDialog, CDialog::Create, CDialog::CreateIndirect, WM_INITDIALOG