pp_ipr
December 26th, 2004, 10:43 PM
Question about SHBrowseForFolder:
There is a folder on my PC, which's size is round about 6G.
In the SHBrowseForFolder's "Browse folder" window:
If i open this folder from My Computer->E:\->...., the browse folder window will pause about 10s.
If i open this folder from Network->... (i have shared this folder), the folder tree will be created immediately.
So i think the SHBrowseForFolder process Local path and newwork path with different method. And i have searched msdn, can't get any information.
Now, i want to implement: open from "My Computer" as fast as open from network. Anyone give me a help?
Thank u very much.
code just like below:
BROWSEINFO bi;
TCHAR szDir[MAX_PATH] = {0};
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
CString strFolder;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = hOwner;
bi.pszDisplayName = 0;
bi.lpszTitle = lpszTips;
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT ;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LONG)lpszDefaultPath;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl, szDir))
{
strFolder = szDir;
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}
//call back funtion
int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
{
TCHAR szDir[MAX_PATH];
switch(uMsg)
{
case BFFM_INITIALIZED:
{
LPCTSTR lpszDefaultPath = (LPCTSTR)pData;
if(lpszDefaultPath && lpszDefaultPath[0])
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpszDefaultPath);
}
else if(GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir))
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
}
else
{
}
}
break;
case BFFM_SELCHANGED:
{
// Set the status window to the currently selected path.
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
{
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
return 1;
}
}
break;
default:
break;
}
return 0;
}
There is a folder on my PC, which's size is round about 6G.
In the SHBrowseForFolder's "Browse folder" window:
If i open this folder from My Computer->E:\->...., the browse folder window will pause about 10s.
If i open this folder from Network->... (i have shared this folder), the folder tree will be created immediately.
So i think the SHBrowseForFolder process Local path and newwork path with different method. And i have searched msdn, can't get any information.
Now, i want to implement: open from "My Computer" as fast as open from network. Anyone give me a help?
Thank u very much.
code just like below:
BROWSEINFO bi;
TCHAR szDir[MAX_PATH] = {0};
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
CString strFolder;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = hOwner;
bi.pszDisplayName = 0;
bi.lpszTitle = lpszTips;
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT ;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LONG)lpszDefaultPath;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl, szDir))
{
strFolder = szDir;
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}
//call back funtion
int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
{
TCHAR szDir[MAX_PATH];
switch(uMsg)
{
case BFFM_INITIALIZED:
{
LPCTSTR lpszDefaultPath = (LPCTSTR)pData;
if(lpszDefaultPath && lpszDefaultPath[0])
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpszDefaultPath);
}
else if(GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir))
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
}
else
{
}
}
break;
case BFFM_SELCHANGED:
{
// Set the status window to the currently selected path.
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
{
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
return 1;
}
}
break;
default:
break;
}
return 0;
}