BruNews
Messages postés
21040
Date d'inscription
jeudi 23 janvier 2003
Statut
Modérateur
Dernière intervention
21 août 2019
17 juil. 2003 à 17:21
pour initailiser le dossier, il faut lui fournir un callback.
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM dwData)
{
switch(uMsg) {
case BFFM_INITIALIZED:
{
SetWindowLong(hwnd, GWL_EXSTYLE, 0x10101);
RECT rc;
GetClientRect(hwnd, &rc);
HWND hLabel = GetDlgItem(hwnd, 0x3742); // titre
if(IsWindow(hLabel)) { // Check if it is a valid window
SetWindowLong(hLabel, GWL_STYLE, 0x50020001);
SetWindowPos(hLabel, NULL, 10, 10, rc.right - 20, 20, SWP_DRAWFRAME);
}
hLabel = GetDlgItem(hwnd, 0x3743); // Add a 3D border to the status text
if(IsWindow(hLabel)) { // Check if it is a valid window
SetWindowLong(hLabel, GWL_EXSTYLE, 0x20004);
SetWindowLong(hLabel, GWL_STYLE, 0x50028201);
SetWindowPos(hLabel, NULL, 5, 40, rc.right - 10, 30, SWP_DRAWFRAME);
}
SendMessage(hwnd, BFFM_SETSELECTION, 1, dwData);
}
break;
case BFFM_SELCHANGED:
{
TCHAR szText[MAX_PATH] = {0};
SHGetPathFromIDList((LPITEMIDLIST) lParam, szText);
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (long) szText);
}
break;
}
return 0;
}
int dlgSelectDir(HWND hOwner, const char* pszTitle, char* pszDirSel)
{
char szTmp[MAX_PATH];
BROWSEINFO bi;
int len = 0;
LPMALLOC pMalloc;
memset(&bi,0,sizeof(BROWSEINFO));
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN |
BIF_VALIDATE | BIF_STATUSTEXT; bi.hwndOwner hOwner; bi.lpszTitle pszTitle;
bi.lParam = (long) pszDirSel; bi.lpfn BrowseCallbackProc; bi.pszDisplayName szTmp;
LPITEMIDLIST lpItemLst = SHBrowseForFolder(&bi);
if(lpItemLst == NULL) return 0;
if(SHGetPathFromIDList(lpItemLst, szTmp)) {
strcpy(pszDirSel, szTmp); len = strlen(pszDirSel);
if(pszDirSel[len - 1] != '\\') {pszDirSel[len++] = '\\'; pszDirSel[len] = 0;}
}
if(SUCCEEDED(SHGetMalloc(&pMalloc))) {pMalloc->Free(lpItemLst); pMalloc->Release();}
return len;
}
BruNews, ciao...