|
-
March 19th, 2009, 06:12 AM
#1
FolderBrowserDialog in MFC
Hi,
I'm building MFC application and i'd like to use FolderBrowserDialog...but it seems there isn't a control in the toolbox with this name like C# and VB...
Is there any other options???
Thanks
-
March 19th, 2009, 06:27 AM
#2
Re: FolderBrowserDialog in MFC
Use SHBrowseForFolder API.
Victor Nijegorodov
-
March 19th, 2009, 07:39 AM
#3
Re: FolderBrowserDialog in MFC
well i tried to use CFileDialog but i'm sure this is not the best way as i have to select the file included in the folder then i get the folder name...
CFileDialog fileDlg(TRUE, NULL, NULL, 4|2, 0, this, NULL);
if (fileDlg.DoModal() == IDOK)
{
CString FolderName = fileDlg.GetFolderPath();
}
also i got an error in this command "Command Assertion Failed" !!!
-
March 19th, 2009, 07:46 AM
#4
Re: FolderBrowserDialog in MFC
 Originally Posted by Fouly
well i tried to use CFileDialog but i'm sure this is not the best way ...
Exactly!
But didn't you read my answer to you? 
Again:
 Originally Posted by Victor
Use SHBrowseForFolder API.
 Originally Posted by Fouly
also i got an error in this command "Command Assertion Failed" !!!
Where?
Did you press the Retry button to debug your code and see the reason of the "Assertion Failed"?
Victor Nijegorodov
-
March 19th, 2009, 07:47 AM
#5
Re: FolderBrowserDialog in MFC
 Originally Posted by Fouly
well i tried to use CFileDialog but i'm sure this is not the best way as i have to select the file included in the folder then i get the folder name...
CFileDialog fileDlg(TRUE, NULL, NULL, 4|2, 0, this, NULL);
if (fileDlg.DoModal() == IDOK)
{
CString FolderName = fileDlg.GetFolderPath();
}
also i got an error in this command "Command Assertion Failed" !!!
Perhaps you missed Victor's post.
From MSDN, about GetFolderPath(). "The dialog box must have been created with the OFN_EXPLORER style; otherwise, the method will fail with an assertion."
-
March 19th, 2009, 07:51 AM
#6
Re: FolderBrowserDialog in MFC
 Originally Posted by Fouly
CFileDialog fileDlg(TRUE, NULL, NULL, 4|2, 0, this, NULL);
And what does this parameter ( 4|2 ) mean?
Victor Nijegorodov
-
March 19th, 2009, 07:54 AM
#7
Re: FolderBrowserDialog in MFC
OH!!! sorry VictorN i didn't read ur message before posting i forgot to refresh :$
Thanks a lot for your help it worked
-
March 19th, 2009, 07:54 AM
#8
Re: FolderBrowserDialog in MFC
 Originally Posted by victorn
and what does this parameter ( 4|2 ) mean? 
4/2 = 2/1 = 2
-
March 19th, 2009, 08:00 AM
#9
-
March 21st, 2009, 05:05 AM
#10
Re: FolderBrowserDialog in MFC
Maybe he finds it easier to use numerical constants instead of names like OFN_OVERWRITEPROMPT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|