HOWTO: Use FileOpen Common Dialog w/OFN_ALLOWMULTIPLESELECTLast reviewed: January 15, 1998Article ID: Q130761 |
The information in this article applies to:
SUMMARYThis article covers the format of file names returned by the FileOpen common dialog with the OFN_ALLOWMULTISELECT style. The FileOpen common dialog can be used to specify the location (drive and directory) and name of a file or a set of files. One of the flags needed to provide mulitple-file selection from the FileOpen common dialog is the OFN_ALLOWMULTISELECT flag. When this flag is used, and the user makes a valid selection, the file or files chosen by the user are returned in the lpstrFile member of the OPENFILENAME structure. The format of the string returned in the lpstrFile member depends on how many files (single or multiple) the user selected. This article assumes that the OFN_EXPLORER Style is set for the file open dialog.
MORE INFORMATIONIf multiple files were selected, the string is of this form:
Drive: \Directory Name\0FileName 1\0FileName 2\0FileName n\0\0.The Directory Name is listed first. Then each file that was selected is listed with a terminating NULL Character, except for the last filename, which is terminated with two NULL characters. The two NULL characters signal the end of the string. If a single file was selected, the string is of this form:
Drive: \Directory Name\FileName\0\0.The Directory Name in this case is not terminated by a NULL character, and the file name is terminated with two NULL characters.
Applications must parse the string returned in the lsptrFile member. In doing so, they should make provisions in the parsing code to have a case where the user can make a single selection (even though the OFN_ALLOWMULTISELECT flag is set) or multiple selections. NOTE: When using OFN_ALLOWMULTISELECT under Windows 95, you need to use the OFN_EXPLORER flag to get the explorer style dialog and NULL terminated strings. If you don't use OFN_EXPLORER with OFN_ALLOWMULTISELECT, you get the old style dialog and space-delimited strings. Keywords : UsrCmnDlg kbui Platform : WINDOWS |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |