EndDialog

Syntax

void EndDialog(hDlg,nResult)

This function terminates a modal dialog box and returns the given result to the DialogBox function that created the dialog box. The EndDialog function is required to complete processing whenever the DialogBox function is used to create a modal dialog box. The function must be used in the dialog function of the modal dialog box and should 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. If called during the WM_INITDIALOG message, the dialog box is terminated before it is shown or before the input focus is set.

EndDialog does not terminate the dialog box immediately. Instead, it sets a flag that directs the dialog box to terminate as soon as the dialog function ends. The EndDialog function returns to the dialog function, so the dialog function must return control to Windows.

Parameter Type/Description  

hDlg HWND Identifies the dialog box to be destroyed.  
nResult int Specifies the value to be returned from the dialog box to the DialogBox function that created it.  

Return Value

None.