dcsimg

WEBINAR:
On-Demand

Application Modernization: What Is It and How to Get Started


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 10: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 10: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
  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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