DialogBox

2.x

  int DialogBox(hinst, lpszDlgTemp, hwndOwner, dlgprc)    
  HINSTANCE hinst; /* handle of application instance */
  LPCSTR lpszDlgTemp; /* address of dialog box template name */
  HWND hwndOwner; /* handle of owner window */
  DLGPROC dlgprc; /* instance address of dialog box procedure */

The DialogBox function creates a modal dialog box from a dialog box template resource.

Parameters

hinst

Identifies an instance of the module whose executable file contains the dialog box template.

lpszDlgTemp

Points to a null-terminated string that names the dialog box template.

hwndOwner

Identifies the window that owns the dialog box.

dlgprc

Specifies the procedure-instance address of the dialog box procedure. The address must be created by using the MakeProcInstance function. For more information about the dialog box procedure, see the description of the DialogProc callback function.

Return Value

The return value specifies the value of the nResult parameter specified in the EndDialog function that is used to terminate the dialog box. The system processes values returned by the dialog box procedure and does not return them to the application. The return value is –1 if the function cannot create the dialog box.

Comments

The CreateWindowEx function is called to create the dialog box. The dialog box procedure then receives a WM_SETFONT message (if DS_SETFONT style was specified) and a WM_INITDIALOG message, and then the dialog box is displayed.

The DialogBox function does not return control until the dialog box procedure terminates the modal dialog box by calling the EndDialog function.

A dialog box can contain up to 255 controls.

Example

The following example uses the DialogBox function to create a modal dialog box:

DLGPROC dlgprc;
HWND hwndParent;


case IDM_ABOUT:
    dlgprc = (DLGPROC) MakeProcInstance(About, hinst);
    DialogBox(hinst, "AboutBox", hwndParent, dlgprc);
    FreeProcInstance((FARPROC) dlgprc);
    break;

See Also

DialogBoxIndirect, DialogBoxIndirectParam, DialogBoxParam, DialogProc, EndDialog, GetDC, MakeProcInstance