CString CaaDlg::OnBrowse(void) //打开浏览对话框
{
// TODO: Add your control notification handler code here
LPMALLOC pMalloc;
/* Gets the Shell's default allocator */
if (::SHGetMalloc(&pMalloc) == NOERROR) //获得pMalloc
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
// Get help on BROWSEINFO struct - it's got all the bit settings.
//设定Browse的属性
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T( "请选择保存的位置" ); //
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
// This next call issues the dialog box.
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) //显示浏览窗口 SHBrowseForFolder
{
if (::SHGetPathFromIDList(pidl, pszBuffer)) //把路径存进pszBuffer中
{
// At this point pszBuffer contains the selected path */.
// Free the PIDL allocated by SHBrowseForFolder.
pMalloc->Free(pidl);
// Release the shell's allocator.
pMalloc->Release();
/************这个有什么作用吗?******************
RECT re;
re.bottom=100;
re.left=50;
re.right=300;
re.top=50;
InvalidateRect(&re,TRUE);//清除路径中的上次的文字
*******************************************/
return bi.pszDisplayName;
//SetDlgItemText(IDC_PATH, bi.pszDisplayName);//填写路径名字
}
else
return "";
}
else
return "";
}
else
return "";
}
{
// TODO: Add your control notification handler code here
LPMALLOC pMalloc;
/* Gets the Shell's default allocator */
if (::SHGetMalloc(&pMalloc) == NOERROR) //获得pMalloc
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
// Get help on BROWSEINFO struct - it's got all the bit settings.
//设定Browse的属性
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T( "请选择保存的位置" ); //
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
// This next call issues the dialog box.
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) //显示浏览窗口 SHBrowseForFolder
{
if (::SHGetPathFromIDList(pidl, pszBuffer)) //把路径存进pszBuffer中
{
// At this point pszBuffer contains the selected path */.
// Free the PIDL allocated by SHBrowseForFolder.
pMalloc->Free(pidl);
// Release the shell's allocator.
pMalloc->Release();
/************这个有什么作用吗?******************
RECT re;
re.bottom=100;
re.left=50;
re.right=300;
re.top=50;
InvalidateRect(&re,TRUE);//清除路径中的上次的文字
*******************************************/
return bi.pszDisplayName;
//SetDlgItemText(IDC_PATH, bi.pszDisplayName);//填写路径名字
}
else
return "";
}
else
return "";
}
else
return "";
}