Folder List
-
-
In one of my apps I need to present the user with a Directory structure (like in windows explorer) . I want to allow the user to only select the folder . Based on this I need to do further actions . Can the usual CFileDialog class serve this purpose ? .
-
OnDisplay() { char str[MAX_PATH ]; BROWSEINFOA lpbi; lpbi.hwndOwner=this->m_hWnd; lpbi.pszDisplayName=str; lpbi.lpszTitle="Test"; lpbi.ulFlags=0; CoInitialize(NULL); OleInitialize(NULL); SHBrowseForFolder(&lpbi); }
For some reason the call to ShBrowseForFolder crashes . -
OnDisplay() { char str[MAX_PATH ]; BROWSEINFOA lpbi; lpbi.hwndOwner=this->m_hWnd; lpbi.pszDisplayName=str; lpbi.lpszTitle="Test"; lpbi.ulFlags=0; CoInitialize(NULL); OleInitialize(NULL); SHBrowseForFolder(&lpbi); }
For some reason the call to ShBrowseForFolder crashes .I found something like this, and it works for me...
CoInitialize(0);
BROWSEINFO bi;
char cc[MAX_PATH];
bi.hwndOwner=m_hWnd;
bi.pidlRoot=0;
bi.pszDisplayName=cc;
bi.lpszTitle="";
bi.ulFlags =0;
bi.lpfn =0;
bi.iImage=0;LPITEMIDLIST p;
p=SHBrowseForFolder(&bi);if(!p)
return;SHGetPathFromIDList(p,cc);
SetDlgItemText(IDC_E_PATH,cc);
IMalloc *pm;
SHGetMalloc(&pm);
pm->Free(p); -
I found something like this, and it works for me...
CoInitialize(0);
BROWSEINFO bi;
char cc[MAX_PATH];
bi.hwndOwner=m_hWnd;
bi.pidlRoot=0;
bi.pszDisplayName=cc;
bi.lpszTitle="";
bi.ulFlags =0;
bi.lpfn =0;
bi.iImage=0;LPITEMIDLIST p;
p=SHBrowseForFolder(&bi);if(!p)
return;SHGetPathFromIDList(p,cc);
SetDlgItemText(IDC_E_PATH,cc);
IMalloc *pm;
SHGetMalloc(&pm);
pm->Free(p); -
In one of my apps I need to present the user with a Directory structure (like in windows explorer) . I want to allow the user to only select the folder . Based on this I need to do further actions . Can the usual CFileDialog class serve this purpose ? .
act_x wrote: Can the usual CFileDialog class serve this purpose ? . Yes, but
SHBrowseForFolder()
is going to be easier.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow