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
Re: FolderBrowserDialog in MFC
Use SHBrowseForFolder API.
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" !!!
Re: FolderBrowserDialog in MFC
Quote:
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? :confused:
Again:
Quote:
Originally Posted by Victor
Use SHBrowseForFolder API.
Quote:
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"?
Re: FolderBrowserDialog in MFC
Quote:
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."
Re: FolderBrowserDialog in MFC
Quote:
Originally Posted by
Fouly
CFileDialog fileDlg(TRUE, NULL, NULL, 4|2, 0, this, NULL);
And what does this parameter ( 4|2 ) mean? :confused:
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 :)
Re: FolderBrowserDialog in MFC
Quote:
Originally Posted by
victorn
and what does this parameter ( 4|2 ) mean? :confused:
4/2 = 2/1 = 2 :d
Re: FolderBrowserDialog in MFC
Quote:
Originally Posted by
Alin
4/2 = 2/1 = 2 :d
:D
But there is a pipe, not a slash between 4 and 2.
Re: FolderBrowserDialog in MFC
Maybe he finds it easier to use numerical constants instead of names like OFN_OVERWRITEPROMPT ;)