有没有能返回目录的对话框? 公共对话框里有吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 char Dir[MAX_PATH]; BROWSEINFO bi; ITEMIDLIST *pidl; //LPITEMIDLIST pidlRoot = NULL;//SHGetFolderLocation(NULL, CSIDL_DESKTOP/*nCSIDL*/, NULL, NULL, &pidlRoot); bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = Dir; bi.lpszTitle = "选择备份文件路径"; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; pidl = SHBrowseForFolder( &bi ); /* Display "Select Folder"dia log box, Get the folder name and convert it into a ITEMLIST data structure. */ if ( pidl == NULL ) Dir[0] = 0; /* Retrieve foldernam e from ITEMLIST structure. */ if (!SHGetPathFromIDList( pidl, Dir )) Dir[0] = 0; if( Dir[0] != 0 ) m_sPath = Dir; http://www.vccode.com/file_show.php?id=1521下有一个很好的封装类CFileDialogST,CFileDialogST 是用 SDK APIs重新实现的一个用MFC CFileDialog类。这个类最有价值的特性是可以显示新的Windows 2000风格的打开/保存 通用对话框。CFileDialogST还包含一个使用通用对话框******选择文件夹的函数******。 char str[80];BROWSEINFO bi;ZeroMemory(&bi,sizeof(BROWSEINFO));LPITEMIDLIST pidl = SHBrowseForFolder(&bi);SHGetPathFromIDList(pidl, str);AfxMessageBox(str); int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData){ if(uMsg == BFFM_INITIALIZED) { LPCTSTR lpInitDir = (LPCTSTR)lpData; ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<long>(lpInitDir)); } else if(uMsg == BFFM_SELCHANGED) { } return 0;}CString T_SelectPath(LPCTSTR lpszTitle, LPCTSTR lpInitDir, HWND hWnd){ CString strFilePath; TCHAR pszBuffer[_MAX_PATH]; BROWSEINFO bi; LPITEMIDLIST pidl; LPMALLOC lpMalloc = NULL; SHGetMalloc(&lpMalloc); if(hWnd == NULL) { CWnd *pWnd = AfxGetMainWnd(); if(pWnd) hWnd = pWnd->GetSafeHwnd(); } bi.hwndOwner = hWnd; bi.pidlRoot = NULL; bi.pszDisplayName = pszBuffer; bi.lpszTitle = lpszTitle; bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; bi.lParam = (LPARAM)lpInitDir; if((pidl = SHBrowseForFolder(&bi)) != NULL) { if(SHGetPathFromIDList(pidl, pszBuffer)) { strFilePath.Format(pszBuffer); if (strFilePath.GetLength() <= 1) return _T(""); if (strFilePath.Right(1) != _T("\\")) strFilePath += _T("\\"); } else return _T(""); } else return _T(""); if(lpMalloc) { lpMalloc->Free(pidl); lpMalloc->Release(); } return strFilePath;}使用方法:T_SelectPath(_T("请选择一个目录"), _T("c:\\winnt"), hWnd); CString strPath = T_SelectPath(_T("请选择一个目录"), _T("c:\\winnt"), hWnd);if(strPath.GetLength() > 0){ ....} 怎么将字符串放到对应的数组中? 对话框之间参数传递 编码转换问题 服务依赖问题 模拟按键的问题 在DLL中不自画的情况下如何实现XP风格的对话框界面 请问怎样编程改变某个文件夹的图标?使用自己定义的图标而不是windows默认图标 资源管理器是如何实现查看网上邻居硬盘资料的?求高手指点!! 请各位指点迷津! DataGrid下标越界why 奇怪呀!SQl SERVER 2000里的Unicode字符类型在VC里没有对应的数据类型? "未处理的异常: 用户断点" 如何追踪
BROWSEINFO bi;
ITEMIDLIST *pidl;
//LPITEMIDLIST pidlRoot = NULL;
//SHGetFolderLocation(NULL, CSIDL_DESKTOP/*nCSIDL*/, NULL, NULL, &pidlRoot);
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = Dir;
bi.lpszTitle = "选择备份文件路径";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder( &bi );
/* Display "Select Folder"dia log box, Get the folder name and convert it into a ITEMLIST data structure. */
if ( pidl == NULL )
Dir[0] = 0;
/* Retrieve foldernam e from ITEMLIST structure. */
if (!SHGetPathFromIDList( pidl, Dir ))
Dir[0] = 0;
if( Dir[0] != 0 )
m_sPath = Dir;
下有一个很好的封装类CFileDialogST,CFileDialogST 是用 SDK APIs重新实现的一个用MFC CFileDialog类。这个类最有价值的特性是可以显示新的Windows 2000风格的打开/保存 通用对话框。
CFileDialogST还包含一个使用通用对话框******选择文件夹的函数******。
BROWSEINFO bi;
ZeroMemory(&bi,sizeof(BROWSEINFO));
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
SHGetPathFromIDList(pidl, str);
AfxMessageBox(str);
{
if(uMsg == BFFM_INITIALIZED)
{
LPCTSTR lpInitDir = (LPCTSTR)lpData;
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE,
reinterpret_cast<long>(lpInitDir));
}
else if(uMsg == BFFM_SELCHANGED)
{
}
return 0;
}CString T_SelectPath(LPCTSTR lpszTitle, LPCTSTR lpInitDir, HWND hWnd)
{
CString strFilePath;
TCHAR pszBuffer[_MAX_PATH];
BROWSEINFO bi;
LPITEMIDLIST pidl;
LPMALLOC lpMalloc = NULL;
SHGetMalloc(&lpMalloc);
if(hWnd == NULL)
{
CWnd *pWnd = AfxGetMainWnd();
if(pWnd)
hWnd = pWnd->GetSafeHwnd();
}
bi.hwndOwner = hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = lpszTitle;
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)lpInitDir;
if((pidl = SHBrowseForFolder(&bi)) != NULL)
{
if(SHGetPathFromIDList(pidl, pszBuffer))
{
strFilePath.Format(pszBuffer);
if (strFilePath.GetLength() <= 1)
return _T("");
if (strFilePath.Right(1) != _T("\\"))
strFilePath += _T("\\");
}
else
return _T("");
}
else
return _T("");
if(lpMalloc)
{
lpMalloc->Free(pidl);
lpMalloc->Release();
}
return strFilePath;
}
使用方法:T_SelectPath(_T("请选择一个目录"), _T("c:\\winnt"), hWnd);
{
....
}