CreateDialog

2.x

  HWND CreateDialog(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 CreateDialog function creates a modeless 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 is the handle of the dialog box that was created, if the function is successful. Otherwise, it is NULL.

Comments

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

The CreateDialog function returns immediately after creating the dialog box.

To make the dialog box appear in the owner window upon being created, use the WS_VISIBLE style in the dialog box template.

Use the DestroyWindow function to destroy a dialog box created by the CreateDialog function.

A dialog box can contain up to 255 controls.

Example

The following example creates a modeless dialog box:

HWND hwndDlgFindBox;
DLGPROC dlgprc = (DLGPROC) MakeProcInstance(FindDlgProc, hinst);

hwndDlgFindBox = CreateDialog(hinst, "dlgFindBox", hwndParent, dlgprc);

See Also

CreateDialogIndirect, CreateDialogIndirectParam, CreateDialogParam, DestroyWindow, MakeProcInstance