选择文件夹对话框
代码
CString CWhiteInputTool_VCDlg::SelectDir()
{
BROWSEINFO bi;
TCHAR szPathName[MAX_PATH];
TCHAR szTitle[] = _T("选择路径");
ZeroMemory(&bi, sizeof(BROWSEINFO));
bi.hwndOwner = GetSafeHwnd();
bi.pszDisplayName = szPathName;
bi.lpszTitle = szTitle;
bi.ulFlags = 0x0040 ;
CString str;
CString strDir; //选择的目录
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
if(idl == NULL)
{
strDir= _T("");
return strDir;
}
SHGetPathFromIDList(idl, str.GetBuffer(MAX_PATH * 2));
str.ReleaseBuffer();
if(str != _T("") && str.GetAt(str.GetLength() - 1) != _T('\\'))
str += _T("\\");
strDir = str;
return strDir;
}
{
BROWSEINFO bi;
TCHAR szPathName[MAX_PATH];
TCHAR szTitle[] = _T("选择路径");
ZeroMemory(&bi, sizeof(BROWSEINFO));
bi.hwndOwner = GetSafeHwnd();
bi.pszDisplayName = szPathName;
bi.lpszTitle = szTitle;
bi.ulFlags = 0x0040 ;
CString str;
CString strDir; //选择的目录
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
if(idl == NULL)
{
strDir= _T("");
return strDir;
}
SHGetPathFromIDList(idl, str.GetBuffer(MAX_PATH * 2));
str.ReleaseBuffer();
if(str != _T("") && str.GetAt(str.GetLength() - 1) != _T('\\'))
str += _T("\\");
strDir = str;
return strDir;
}