DOC: OPENFILENAME lpstrInitialDir Documented Incorrectly (86920)



The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) 3.1

This article was previously published under Q86920
3.10 WINDOWS kbprg kbdocerr

SUMMARY

The lpstrInitialDir member of the OPENFILENAME data structure is documented incorrectly on page 376 of the "Microsoft Windows Software Development Kit: Programmer's Reference, Volume 3: Message, Structures, and Macros" manual for version 3.1.

The description states that if the lpstrFile member of the same structure specifies a valid path, the common dialog box procedure will use the path specified by this string instead of the path specified by lpstrInitialDir. This statement is incorrect; the common dialog box procedure uses the path specified by lpstrInitialDir regardless of the path specified in lpstrFile. If lpstrInitialDir is set to NULL, the system sets the initial directory to the current directory.

MORE INFORMATION

An application can implement the documented functionality through either of two following methods:

Method 1

If lpstrFile specifies a valid path and a complete filename such as \\AUTOEXEC.BAT, perform the following three steps:

  1. Parse the string.
  2. Extract the path from the string.
  3. Set the lpstrInitialDir member to the extracted path.

Method 2

If lpstrFile specifies a valid path and a file filter such as \\*.BAT, perform the following four steps, as follows:

  1. Implement a common dialog box hook function.
  2. Modify the Flags member of the OPENFILENAME data structure to include the OFN_ENABLEHOOK flag.
  3. Set the lpfnHook member of the OPENFILENAME data structure to point to the hook function.
  4. In the hook function, process the WM_INITDIALOG message to send a WM_COMMAND message with wParam set to IDOK. Doing so causes the common dialog to change the current directory to the directory specified in lpstrFile.

Modification Type:MinorLast Reviewed:2/14/2005
Keywords:kb16bitonly kbCmnDlg kbCmnDlgFileO kbdocfix KB86920