int DialogBoxIndirectParam(hinst, hglbDlgTemp, hwndOwner, dlgprc, lParamInit) | |||||
HINSTANCE hinst; | /* handle of application instance | */ | |||
HGLOBAL hglbDlgTemp; | /* handle of memory with dialog box template | */ | |||
HWND hwndOwner; | /* handle of owner window | */ | |||
DLGPROC dlgprc; | /* instance address of dialog box procedure | */ | |||
LPARAM lParamInit; | /* initialization value | */ |
The DialogBoxIndirectParam function creates a modal 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.
hglbDlgTemp
Identifies the 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 about the dialog box procedure, see the description of the DialogProc callback function.
lParamInit
Specifies a 32-bit value that DialogBoxIndirectParam passes to the dialog box when the WM_INITDIALOG message is being processed.
The return value is 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.
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 DialogBoxIndirectParam 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.
The following example uses the DialogBoxIndirectParam function to create a modal 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 TEMPLATE_SIZE 100
HGLOBAL hglbDlgTemp;
DLGPROC dlgprc;
int result;
HWND hwndParent;
WORD wInitParm1, wInitParm2;
/* Allocate a global memory object for the dialog box template. */
hglbDlgTemp = GlobalAlloc(GHND, TEMPLATE_SIZE);
.
. /* Build a DLGTEMPLATE structure in the memory object. */
.
dlgprc = (DLGPROC) MakeProcInstance(DialogProc, hinst);
result = DialogBoxIndirectParam(hinst, hglbDlgTemp, hwndParent,
dlgprc, (LPARAM) MAKELONG(wInitParm1, wInitParm2));
DialogBox, DialogBoxIndirect, DialogBoxParam, DialogProc, EndDialog, MakeProcInstance