Microsoft KB Archive/74610

{|
 * width="100%"|

INFO: Common Dialog Boxes and the WM_INITDIALOG Message

 * }

Q74610

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), on platform(s):
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51
 * Microsoft Windows Software Development Kit (SDK) 3.1

-

SUMMARY
An application using the common dialog box library (COMMDLG.DLL) can override any information initialized in the DLL by handling the WM_INITDIALOG message in its dialog hook function. If the application is using a private dialog template, it should also initialize all private dialog items while handling this message.

After processing the WM_INITDIALOG message, the hook function should return FALSE if it has set the focus to a dialog control, and return TRUE if Windows should set the focus.

MORE INFORMATION
For example, consider an application that is using the Open File common dialog box (via GetOpenFileName) but does not want the Drives combo box to appear in the dialog box. Since all dialog items in the standard dialog template must be included in the application's private dialog template, the application will need to include code to disable and hide the Drives combo box and the corresponding &quot;Drives:&quot; static text control. This code would be implemented in the WM_INITDIALOG case of the dialog hook function, as follows:

  case WM_INITDIALOG: hWnd = GetDlgItem( hDlg, cmb2 ); // Get Drives combo box handle EnableWindow( hWnd, FALSE );     // No longer receives input, // no longer a tabstop SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_HIDEWINDOW );

hWnd = GetDlgItem( hDlg, stc4 ); // Get &quot;Drives:&quot; static control EnableWindow( hWnd, FALSE );     // no longer an accelerator SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_HIDEWINDOW);

// Initialize private dialog items here...

return( TRUE );                  // Let Windows set the focus. Additional query words:

Keywords : kbCmnDlg kbOSWinNT350 kbOSWinNT351 kbGrpDSUser

Issue type : kbinfo

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch