출처 : http://codeguru.earthweb.com/mfc/comments/5889.shtml
[[ Starting SHBrowseForFolder from arbitrary directory is easy ]]
This is very easy...
[[ Starting SHBrowseForFolder from arbitrary directory is easy ]]
This is very easy...
// this is how we set the initial directory
int CALLBACK MyBrowseCallbackProc(
HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData
)
{
switch (uMsg) {
case BFFM_INITIALIZED:
::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData );
break;
}
return 0;
}
void BrowseForDirectory( CWnd* pWndOwner, LPCTSTR title, CString& folderName )
{
TCHAR path[MAX_PATH];
LPTSTR pFolderName = folderName.GetBuffer(folderName.GetLength());
BROWSEINFO browse;
browse.hwndOwner = pWndOwner->GetSafeHwnd();
browse.pidlRoot = NULL;
browse.pszDisplayName = pFolderName;
browse.lpszTitle = title;
browse.ulFlags = BIF_RETURNONLYFSDIRS;
browse.lpfn = MyBrowseCallbackProc;
browse.lParam = (LPARAM)pFolderName;
LPITEMIDLIST pidl = SHBrowseForFolder(&browse);
folderName.ReleaseBuffer();
if (NULL != pidl) {
if (SHGetPathFromIDList( pidl, path )) {
folderName = path;
}
}
}
댓글
댓글 쓰기