CDirSelDialog : Folder Selection Dialog

CDirSelDialog is derived from CFileDialog. It is customized to show only directories, and it has the following additional features :

  • You can optionally see the files in a directory, before you decide to choose one 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.
  • In the editbox, you can type in directory name or .. or whatever, which you want 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.
  • You can choose to navigate to the previous directories, which you have visited earlier, using the bottom combobox.
  • From the ComboBox, you can copy the directory name into clipboard if reqd.
  • 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



    Comments

    Leave a Comment
    • Your email address will not be published. All fields are required.

    Top White Papers and Webcasts

    • Data center, IT and Operations Architects can now secure their web applications whether they are on-premise, in a virtual environment or in the most popular public cloud, Amazon Web Services (AWS). This blueprint document provides guidance on architecting security for cloud-based web applications.

    • By now, every company has a business continuity (BC) plan, right? Not quite. Many US businesses aren't equipped to deal with major disruptions. The adoption of BC practices remains low, as many a C-suite folks simply have the "it can't happen to us" mentality or they have a subjective notion of risk, assuming that they can withstand disaster. Read this article bundle to learn why your BC plan can't wait, tips on how to get started with your plan and what it should contain, and much more.

    Most Popular Programming Stories

    More for Developers

    RSS Feeds

    Thanks for your registration, follow us on our social networks to keep up-to-date