WM_INITDIALOG
hwndFocus = (HWND) wParam; /* handle of control for focus */
dwData = lParam; /* application-specific data */
The WM_INITDIALOG message is sent to a dialog box procedure immediately before the dialog box is displayed.
hwndFocus
Value of wParam. Identifies the first control in the dialog box that can be given the input focus. Usually, this is the first control in the dialog box with the WS_TABSTOP style.
dwData
Value of lParam. Specifies application-specific data that was passed by the function used to create the dialog box if the dialog box was created by one of the following functions:
CreateDialogParam DialogBoxIndirectParam DialogBoxParam
An application should return nonzero to set the input focus to the control identified by the hwndFocus parameter. An application should return zero if the dialog box procedure uses the SetFocus function to set the input focus to a different control in the dialog box.
This example changes the font used by controls in a dialog box to a font that is not bold.
HFONT hDlgFont;
LOGFONT lFont;
case WM_INITDIALOG:
/* Get dialog box font and create version that is not bold. */
hDlgFont = (HFONT) NULL;
if ((hDlgFont = (HFONT) SendMessage(hdlg, WM_GETFONT, 0, 0L))) {
if (GetObject(hDlgFont, sizeof(LOGFONT), (LPSTR) &lFont)) {
lFont.lfWeight = FW_NORMAL;
if (hDlgFont = CreateFontIndirect((LPLOGFONT) &lFont)) {
SendDlgItemMessage(hdlg, ID_CTRL1, WM_SETFONT,
hDlgFont, 0L);
SendDlgItemMessage(hdlg, ID_CTRL2, WM_SETFONT,
hDlgFont, 0L);
.
. /* Set font for remaining controls. */
.
}
}
}
return TRUE;
CreateDialogParam, DialogBoxIndirectParam, DialogBoxParam, SetFocus