1.7.3 Return Values from a Dialog Box

The DialogBox function that creates a modal dialog box does not return until the dialog function has called the EndDialog function to signal the end of the dialog box. When control finally returns from the DialogBox function, the return value is equal to the value specified in the EndDialog function. This means a modal dialog box can return a value through the EndDialog function.

Modeless dialog boxes cannot return values in this way since they do not use the EndDialog function to terminate execution and do not return control in the same way a modal dialog box does. Instead, modeless dialog boxes return values to their parent windows by using the SendMessage function to send a notification message to the parent window. Although Windows does not explicitly define the content of a notification message, most applications use a WM_COMMAND message with an integer value that identifies the dialog box in the wParam parameter and the return value in the lParam parameter. Modal dialog boxes may also use this technique to return values to their parent windows before terminating.