FILE: Directory Picker Sample Using Modified CFileDialogLast reviewed: January 15, 1998Article ID: Q105497 |
The information in this article applies to:
SUMMARYThe default implementation of CFileDialog allows the user to select a specific file from any drive/directory on the computer. It is possible to derive a class from CFileDialog, creating a new class that allows the user to select only a directory. In addition to deriving a new class, this approach also requires that a custom template be used in conjunction with the new dialog box. The Directory Picker (DIRPK) sample implements this functionality. The following file is available for download from the Microsoft Software Library:
~ Dirpk.exe (size: 79675 bytes)For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online ServicesDIRPK.EXE was archived as a self-extracting file using the PKware file- compression utility. The archived file contains subdirectories, and therefore, the -d switch needs to be used when decompressing the file to disk.
MORE INFORMATIONNOTE: The DIRPK sample was designed using the old style of common file dialogs and will work as intended only on Windows NT 3.51. On Windows 95 and future versions of NT (4.0), if you want to use the old style of common file dialogs, insure that:
m_ofn.Flags &= ~OFN_EXPLORER;before calling DoModal() on the CFileDialog object. It is likely, however, that this behavior will change under future versions of Windows and the old style of common file dialogs will go away. The best way to search for a folder instead of a specific file is to use the new ::SHBrowseForFolder() SDK function. The following steps use the DIRPK sample to derive a class from CFileDialog which allows the user to select only a directory:
Sample Code
CMyFileDlg cfdlg(FALSE, NULL, NULL, OFN_SHOWHELP | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE, NULL, m_pMainWnd); cfdlg.m_ofn.hInstance = AfxGetInstanceHandle(); cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(FILEOPENORD); if (IDOK==cfdlg.DoModal()) ...OK processing... else ...Error processing... |
Additional query words: getopenfilename commdlg dirpkr dirpick dirpicker
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |