The DialogBox function that creates a modal dialog box does not return until the dialog box procedure has called the EndDialog function to signal the destruction 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 because they do not use the EndDialog function to close and do not return control in the same way a modal dialog box does. Instead, a modeless dialog box returns values to its parent window 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. A modal dialog box can also use this technique to return values to its parent window before closing.