簡介
中文翻譯為"資料夾拾取對話框".是Visual C++ 2008中新引入的針對資料夾選擇對話框設計的類,此類替代了傳統的SDK方法,而且具有更好的外觀.但是,此類僅適用於vista及以上windows作業系統.
示例
構造函式:
CFolderPickerDialog( LPCTSTR lpszFolder = NULL, DWORD dwFlags = 0, CWnd* pParentWnd = NULL, DWORD dwSize = 0);
範例:
CFolderPickerDialog fd(NULL,0,this,0);
int ret=fd.DoModal();
if(ret==IDOK)
{
CString des;
des=fd.GetFolderPath();
}
採用Win API實現如下:
BROWSEINFO bi;
char path[MAX_PATH];
char title[] = "Select Directory";
ZeroMemory(&bi,sizeof(bi));
bi.hwndOwner = this->m_hWnd;
bi.pszDisplayName = path;
bi.lpszTitle = title;
bi.ulFlags = 0x0040;
CString dir;
LPITEMIDLIST list = SHBrowseForFolder(&bi);
if(list == NULL)
dir = "";
else
{
SHGetPathFromIDList(list,path);
dir.Format("%s",path);
}
此API版本不僅適用於XP系統,還適用vista以及win7以上系統.但在外觀界面有所差異.