CFileDialog class that only displays folders

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

Download Source Code and Example


The CFolderDialog class is derived from CFileDialog. The major difference between the two classes is that while the CFileDialog class displays both folders and files, the CFolderDialog class can be used in situations where the application only wants to display folders. Below is a code snippet showing how easy it is to use this class. Please note that the the constructor for the CFolderDialog takes a CString pointer. This variable will contain the name of the folder that was selected by the end user when the DoModal function call returns.

	CString pathSelected;
	CFolderDialog dlg(&pathSelected);
	if (dlg.DoModal() == IDOK)
	{
		// pathSelected contain the selected folder.
		AfxMessageBox(pathSelected); 
	}

Last updated: 29 April 1998



Comments

  • OnInitDone not being call using this class

    Posted by Manu Goel on 09/04/2014 03:47am

    Hello, Thanks for such a good class. But, I am trying to use this class in one of my SDI application, where i want to display a folder select dialog. I am Having Windows 7 SP1 32bit with visual studio 2013. The problem is that OnInitDone is never called. This is what I have done: int CMyClass::GetFolderPath(CString& sDirPath) { CFolderDialog dlgDir(sDirPath); if (IDOK == dlgDir.DoModal()) { } return S_OK; } So the behavior is wired, as it never selects a folder, just always goes in to it.

    Reply
  • Not able to get this code to work! OnInitDone not being called.

    Posted by Manu Goel on 09/04/2014 03:38am

    Hello Mihai Filimon, First of all thanks for such a great class. But i am not able to get this to work. i am on window 7 with SP1 and using Visual Studio 2013 to build a SDI application where i want to display a folder select dialog with the help of your class. But the OnInitDone menthod is never called. Plase help me identify what could be the problem. Thanks & Regards Manu Goel

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

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

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