int CALLBACK BrowseCallBackProc(HWND hwnd, UINT uMsg, LPARAM lParam,LPARAM lpData)
{
if(uMsg==BFFM_SELCHANGED||uMsg==BFFM_INITIALIZED)
{
if(uMsg==BFFM_INITIALIZED)
{
::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,LPARAM(lpData));
}
}
return 0;
}
String strSelPath;
void __fastcall TForm1::Button4Click(TObject *Sender)
{TCHAR szPath[MAX_PATH];
ZeroMemory(szPath,MAX_PATH);
TCHAR strPath[255] = TEXT("d:\\");
BROWSEINFO bInfo;
bInfo.hwndOwner = this->Handle;
// bInfo.pszDisplayName = szPath;
bInfo.lpszTitle = TEXT("");
bInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
bInfo.lpfn = BrowseCallBackProc;
bInfo.lParam = (LPARAM)strPath;
LPITEMIDLIST lpDlist;
lpDlist = SHBrowseForFolder(&bInfo);
if(lpDlist)
{
SHGetPathFromIDList(lpDlist,szPath);
strSelPath = szPath;
this->Caption = strSelPath;
}
IMalloc *imalloc = 0;
if(SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(lpDlist);
imalloc->Release();
}
}