CDirSelDialog is derived from CFileDialog. It is customized to show only directories, and
it has the following additional features :
directory for a particular purpose. This feature was lacking in previous versions
of directory selection dialogs, either a class was derived from CFileDialog or
a class abstacted the API function SHBrowseForFolder.
to navigate to. However, CDirSelDialog will not let you type the masks, like *.h or *.*
etc, to view the files within the listview control. If you want to see the files,
you can view them in the separate listbox, for which no mask is used, *.* being used always.
using the bottom combobox.
Finally, thanks to Mihai Filimon for
his article on Folder Dialog, providing the windowproc hook to start with. In his
article, he had used “*..*” intentionally to avoid showing files in the listview control.
However, I have used “.*” as file mask for the listview control, to get better results.
Sample Usage Code for CDirSelDialog would be
CDirSelDialog dirdlg;
if( dirdlg.DoModal() == IDOK )
{
AfxMessageBox( dirdlg.GetDirName() );
}
Download demo & source code – 22 Kb