HWND CreateDialogIndirectParam(hinst, lpvDlgTmp, hwndOwner, dlgprc, lParamInit) | |||||
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 | */ | |||
LPARAM lParamInit; | /* initialization value | */ |
The CreateDialogIndirectParam function creates a modeless dialog box from a dialog box template in memory. Before displaying the dialog box, the function passes an application-defined value to the dialog box procedure as the lParam parameter of the WM_INITDIALOG message. An application can use this value to initialize dialog box controls.
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.
lParamInit
Specifies the value to pass to the dialog box when processing the WM_INITDIALOG message.
The return value is the window handle of the dialog box if the function is successful. Otherwise, it is NULL.
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 CreateDialogIndirectParam 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 CreateDialogIndirectParam function.
A dialog box can contain up to 255 controls.
The following example calls the CreateDialogIndirectParam function to create a modeless dialog box from a dialog box template in memory. The example uses the lParamInit parameter to send two initialization parameters, wInitParm1 and wInitParm2, to the dialog box procedure when the WM_INITDIALOG message is being processed.
#define MEM_LENGTH 100
HGLOBAL hglbDlgTemp;
BYTE FAR* lpbDlgTemp;
DLGPROC dlgprc = (DLGPROC) MakeProcInstance(DialogProc, hinst);
HWND hwndDlg;
/* Allocate a global memory object for the dialog box template. */
hglbDlgTemp = GlobalAlloc(GHND, MEM_LENGTH);
.
. /* Build a DLGTEMPLATE structure in the memory object. */
.
lpbDlgTemp = GlobalLock(hglbDlgTemp);
hwndDlg = CreateDialogIndirectParam(hinst, lpbDlgTemp,
hwndParent, dlgprc, 0);
CreateDialog, CreateDialogIndirect, CreateDialogParam, DestroyWindow, MakeProcInstance