Choix d'un repertoire

olivieragnes Messages postés 6 Date d'inscription jeudi 3 juillet 2003 Statut Membre Dernière intervention 18 juillet 2003 - 17 juil. 2003 à 16:14
cs_Xentor609 Messages postés 258 Date d'inscription jeudi 20 mars 2003 Statut Membre Dernière intervention 16 août 2004 - 18 juil. 2003 à 16:59
Je recherche de l'aide afin d'afficher sur une boite de dialogue, un arbre déroulant ( comme un mini explorateur de Windows ).
Ceci afin de selectionner un répertoire et de récupérer le chemin en retour.
En VC++ 6.0
Merci à tous.

9 réponses

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 à 16:17
mes dources feront ton bonheur.
BruNews, ciao...
0
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 à 16:18
dources => SOURCES sans faute de frappe.
BruNews, ciao...
0
cs_Xentor609 Messages postés 258 Date d'inscription jeudi 20 mars 2003 Statut Membre Dernière intervention 16 août 2004
17 juil. 2003 à 16:24
Si jamais ca peut t'interesser, j'ai une source sur un mim-explorateur windows:
http://www.cppfrance.com/article.aspx?Val=2024
Bye,Xentor609
0
olivieragnes Messages postés 6 Date d'inscription jeudi 3 juillet 2003 Statut Membre Dernière intervention 18 juillet 2003
17 juil. 2003 à 16:51
Merci, pour ce qui est de l'utilisation de SHBrowseForFolder, ca marche mais à chaque ouverture de la popup, je me retrouve dans le repertoire bureau. je souhaiterais pouvoir choisir mon repertoire de demarage.

Mais ce que je voudrais, c'est un affichage permanent sur ma fenetre d'une hierarchie de repertoire jusqu' a mon rep de travail

Voici le code que j'utilise avec SHBrowseForFolder

BROWSEINFO bi;
char Buffer[MAX_PATH];
CWnd Win;
char Result[MAX_PATH];
ITEMIDLIST *il;
CString name; // nom du fichier modifié
CString type; // extension en cours

Win.GetActiveWindow();

bi.hwndOwner=Win;
bi.pidlRoot=NULL;
bi.pszDisplayName=&Buffer[0];
bi.lpszTitle="Choisir un répertoire ...";
bi.ulFlags=BIF_VALIDATE|BIF_EDITBOX ;
bi.lpfn=NULL;

if ((il=SHBrowseForFolder(&bi))==NULL) return ;
SHGetPathFromIDList(il,&Result[0]);

name.Format("%s\",&Result[0]);

if (name!="")
{
m_Path0 =name;
UpdateData(false);
DisplayList();

}
return ;
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
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...
0
olivieragnes Messages postés 6 Date d'inscription jeudi 3 juillet 2003 Statut Membre Dernière intervention 18 juillet 2003
17 juil. 2003 à 17:35
merci, mais je n'ai pas les sources .cpp et l'executable propose les repertoire c et d mais un clic ne fait pas apparaitre le contenu
???
0
cs_Xentor609 Messages postés 258 Date d'inscription jeudi 20 mars 2003 Statut Membre Dernière intervention 16 août 2004
17 juil. 2003 à 17:42
Oups, je savais pas que tu tournais sous Win9x, en fait, ce code marche uniquement sur XP, mais si jamais ca t'interesse je posterai la MAJ au cours de la semaine prochaine, qui fonctionne sur XP et 9x et aussi d'autres fonction (differencier les icones,executer les programmes,supprimer,creer fichier,dossier....)
Bye,Xentor609
0
olivieragnes Messages postés 6 Date d'inscription jeudi 3 juillet 2003 Statut Membre Dernière intervention 18 juillet 2003
18 juil. 2003 à 12:05
Oui, merci de m'en informer.

De plus si tu peux donner les soures c++
0
cs_Xentor609 Messages postés 258 Date d'inscription jeudi 20 mars 2003 Statut Membre Dernière intervention 16 août 2004
18 juil. 2003 à 16:59
Ben, je comprends pas pourquoi les sources c++, le fihcier .cpp se trouve a l'interieur ("eXPlorer.cpp"). Bon de toute facon c pas bien grave, puisque je ne tarderai pas a poster la MAJ.
Bye,Xentor609
0
Rejoignez-nous