Visual Basic 6 Black Book:Windows Common Dialogs
You can set a wide variety of options when you display File Open and File Save As
dialog boxes by setting the Common Dialog control’s Flags property. Here are the
• cdlOFNAllowMultiselect—&H200; specifies that the File Name list box
allows multiple selections.
• cdlOFNCreatePrompt—&H2000; the user can select more than one file at
runtime by pressing the Shift key and using the up arrow and down arrow keys
to select the desired files. When this is done, the FileName property returns a
string containing the names of all selected files. The names in the string are
delimited by spaces.
• cdlOFNCreatePrompt—&H2000; specifies that the dialog box prompts the
user to create a file that doesn’t currently exist. This flag automatically sets the
cdlOFNPathMustExist and cdlOFNFileMustExist flags.
• cdlOFNExplorer—&H80000; displays the Explorer-like Open A File dialog
box template. Works with Windows 95 and Windows NT 4.
• cdlOFNExtensionDifferent—&H400; indicates that the extension of the
returned file name is different from the extension specified by the DefaultExt
property. This flag isn’t set if the DefaultExt property is Null, if the extensions
match, or if the file has no extension. This flag value can be checked upon
closing the dialog box. This can be useful if you want to track the kind of file
the user wants to open.
• cdlOFNFileMustExist—&H1000; specifies that the user can enter only
names of existing files in the File Name text box. If this flag is set and the user
enters an invalid file name, a warning is displayed. This flag automatically sets
the cdlOFNPathMustExist flag.
• cdlOFNHelpButton—&H10; causes the dialog box to display the Help
• cdlOFNHideReadOnly—&H4; hides the Read Only checkbox.
• cdlOFNLongNames—&H200000; enables the use of long file names.
• cdlOFNNoChangeDir—&H8; forces the dialog box to set the current
directory to what it was when the dialog box was opened.
• cdlOFNNoDereferenceLinks—&H100000; disables the use of shell links
(also known as shortcuts). By default, choosing a shell link causes it to be
interpreted by the shell.
• cdlOFNNoLongNames—&H40000; disables long file names.
• cdlOFNNoReadOnlyReturn—&H8000; specifies that the returned file
won’t have the Read Only attribute set and won’t be in a write-protected
• cdlOFNNoValidate—&H100; specifies that the Common Dialog allows
invalid characters in the returned file name.
• cdlOFNOverwritePrompt—&H2; causes the Save As dialog box to generate
a message box if the selected file already exists. The user must confirm whether
to overwrite the file.
• cdlOFNPathMustExist—&H800; specifies that the user can enter only valid
paths. If this flag is set and the user enters an invalid path, a warning message is
file:///E|/Program%20Files/KaZaA/My%20Shared%...Basic%20-%20%20Black%20Book/ch11/350-353.html (3 of 4) [7/31/2001 8:59:30 AM]