BROWSEINFO & ITEMIDLIST

Résolu
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 - 12 janv. 2007 à 21:33
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 - 13 janv. 2007 à 17:18
Salut,
J'aimerais initialiser le membre pidlRoot de la structure BROWSEINFO pour utiliser avec la fonction SHBrowseForFolder. (Qui devrais mettre un répertoire choisit au root de la liste des repertoires)

LPITEMIDLIST lpItemRoot = 0;  // Devra contenir l'ID du repertoire
IMalloc *pMalloc = 0;
::SHGetMalloc(&pMalloc);            // Accède à l'allocateur du système

// ICI : Comment accéder à la définition de l'ITEMIDLIST

pMalloc->Free(lpItem);                  // Libère l'item
pMalloc->Release();                      // Plus besoin de ce pointeur 

// Ensuite
/*BROWSEINFO::*/browseInfo.pidlRoot = lpItemRoot;

Sur cppFrance tous les codes mettent le root à NULL.
Sur MSDN, peu d'infos sur ce sujet.
Si vous avez des infos, merci d'avance...

3 réponses

cs_vicenzo Messages postés 178 Date d'inscription mardi 16 août 2005 Statut Membre Dernière intervention 25 août 2010 1
13 janv. 2007 à 11:01
Si ton problème est d'initialiser d'ouvrir la boite de dialog sur un répertoire de ton choix, tu peux utiliser le code suivant qui utilise un callback pour sélectionner le réportoire :

static char path[1024];

int CALLBACK browse_folder_callback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
    switch (uMsg)
    {
        case BFFM_INITIALIZED:
        {
            SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) path);
            break;
        }
    }

    return FALSE;
}

int browse_folder(char *folder, size_t *size) /* in -> root, out -> répertoire choisi */
{
    BROWSEINFO bi;
    LPITEMIDLIST pidl;

    if (!folder)
        return 0;

    strncpy(path, folder, sizeof(path)-1);
    memset(&bi, 0, sizeof(bi));

    bi.lpszTitle    = "Choisissez un répertoire";
    bi.lpfn        = browse_folder_callback;

       pidl = SHBrowseForFolder(&bi);
   
    if (pidl)
    {
        IMalloc * imalloc = 0;

            if ( SHGetPathFromIDList (pidl, path))
            {
            strcat(path, "\");
            strncpy(folder, path, size);
        }

        if (SUCCEEDED(SHGetMalloc(&imalloc)))
        {
            imalloc->Free (pidl);
            imalloc->Release();
        }
    }

    return 1;
}

J'espère que ca peut aider...
3
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
13 janv. 2007 à 15:00
SELECTEUR DOSSIER REDUIT (WIN32)
http://www.cppfrance.com/code.aspx?ID=36936

ciao...
BruNews, MVP VC++
3
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
13 janv. 2007 à 17:18
Parfait.
Merci pour vos réponses...
0
Rejoignez-nous