CreateDialogIndirect

2.x

  HWND CreateDialogIndirect(hinst, lpvDlgTmp, hwndOwner, dlgprc)    
  HINSTANCE hinst; /* handle of application instance */
  const void FAR* lpvDlgTmp; /* address of dialog box template */
  HWND hwndOwner; /* handle of owner window */
  DLGPROC dlgprc; /* instance address of dialog box procedure */

The CreateDialogIndirect function creates a modeless dialog box from a dialog box template in memory.

Parameters

hinst

Identifies the instance of the module that will create the dialog box.

lpvDlgTmp

Points to a global memory object that contains a dialog box template used to create the dialog box. This template is in the form of a DialogBoxHeader structure. For more information about this structure, see Chapter 7, “Resource Formats Within Executable Files,” in the Microsoft Windows Programmer's Reference, Volume 4.

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, see the description of the DialogProc callback function.

Return Value

The return value is the window handle of the dialog box 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 CreateDialogIndirect 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 CreateDialogIndirect function.

A dialog box can contain up to 255 controls.

Example

The following example uses the CreateDialogIndirect function to create a dialog box from a dialog box template in memory:

DLGPROC dlgprc = (DLGPROC) MakeProcInstance(DialogProc, hinst);
HWND hdlg;
BYTE FAR* lpbDlgTemp;

.
. /* Allocate global memory and build a dialog box template. */
.

hdlg = CreateDialogIndirect(hinst, lpbDlgTemp, hwndParent, dlgprc);

See Also

CreateDialog, CreateDialogIndirectParam, CreateDialogParam, DestroyWindow, MakeProcInstance