int DialogBoxParam(hinst, lpszDlgTemp, hwndOwner, dlgprc, lParamInit) | |||||
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 | */ | |||
LPARAM lParamInit; | /* initialization value | */ |
The DialogBoxParam function creates a modal dialog box from a dialog box template resource. Before displaying the dialog box, the function passes an application-specified 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 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.
lParamInit
Specifies a 32-bit value that DialogBoxParam passes to the dialog box procedure when creating the dialog box.
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.
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 DialogBoxParam 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 DialogBoxParam function to create a modal dialog box. The function passes the dialog box a pointer to a string when the WM_INITDIALOG message is being processed.
DLGPROC dlgprc;
HWND hwndParent;
PSTR pszFileName;
int result;
case IDM_OPEN:
dlgprc = (DLGPROC) MakeProcInstance(FileOpenProc, hinst);
result = DialogBoxParam(hinst, "FileOpenBox", hwndParent,
dlgprc, MAKELPARAM(pszFileName, 0));
FreeProcInstance((FARPROC) dlgprc);
break;
DialogBox, DialogBoxIndirect, DialogBoxIndirectParam, DialogProc, EndDialog, MakeProcInstance