#include <windows.h>
#include <shlobj.h>
int CALLBACK BrowseForFolderCallback(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
{
char szPath[MAX_PATH];
switch(uMsg)
{
case BFFM_INITIALIZED:
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
break;
case BFFM_SELCHANGED:
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szPath))
{
SendMessage(hwnd, BFFM_SETSTATUSTEXT,0,(LPARAM)szPath);
}
break;
}
return 0;
}
BOOL BrowseFolders(HWND hwnd, LPSTR lpszFolder, LPSTR lpszTitle)
{
BROWSEINFO bi;
char szPath[MAX_PATH + 1];
LPITEMIDLIST pidl;
BOOL bResult = FALSE;
LPMALLOC pMalloc;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
bi.hwndOwner = hwnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = lpszTitle;
bi.ulFlags = BIF_STATUSTEXT; //BIF_EDITBOX
bi.lpfn = BrowseForFolderCallback;
bi.lParam = (LPARAM)lpszFolder;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl,szPath))
{
bResult = TRUE;
strcpy(lpszFolder, szPath);
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}
return bResult;
}
From: http://www.nirsoft.net/vc/brfolder.html
Title:
Displaying Browse Folders dialog
Description:
#include <windows.h> #include <shlobj.h> int CALLBACK BrowseForFolderCallback(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) {...
...
Rating:
4