What Is a Dialog Box?

A dialog box is a pop-up window that an application uses to display or prompt for information. Dialog boxes are typically used to prompt the user for the information needed to complete a command. A dialog box contains one or more controls with which the user can enter text, choose options, and direct the action of a particular command.

You have already seen a dialog box in the Generic application: the About dialog box. This dialog box contains static text controls that provide information about the application, and a push-button control that the user can use to close the dialog box and return to the main window. To process a dialog box, you need to supply a dialog-box template, a dialog function, and some means to call up the dialog box.

A dialog-box template is text that describes the dialog box and the controls it contains. You can use either a text editor or the Dialog Editor to create the template. Once you have created the template, add it to your resource script file.

Summary: Dialog-box messages are processed in a dialog function.

A dialog function is a callback function; Windows calls the dialog function and passes it messages for the dialog box. Although a dialog function is similar to a window function, Windows carries out special processing for dialog boxes. Therefore, the dialog function does not have the same responsibilities as a window function.

The most common way to display a dialog box is in response to menu input. For example, the Open and Save As commands in the File menu both require additional information to complete their tasks; both display dialog boxes to prompt for the additional information.

There are two types of dialog boxes: modal and modeless.