Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Folder List

Folder List

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    act_x
    wrote on last edited by
    #1

    In one of my apps I need to present the user with a Directory structure (like in windows explorer) . I want to allow the user to only select the folder . Based on this I need to do further actions . Can the usual CFileDialog class serve this purpose ? .

    M D 2 Replies Last reply
    0
    • A act_x

      In one of my apps I need to present the user with a Directory structure (like in windows explorer) . I want to allow the user to only select the folder . Based on this I need to do further actions . Can the usual CFileDialog class serve this purpose ? .

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      use ShBrowseForFolder


      Maximilien Lincourt Your Head A Splode - Strong Bad

      A 1 Reply Last reply
      0
      • M Maximilien

        use ShBrowseForFolder


        Maximilien Lincourt Your Head A Splode - Strong Bad

        A Offline
        A Offline
        act_x
        wrote on last edited by
        #3

        OnDisplay() { char str[MAX_PATH ]; BROWSEINFOA lpbi; lpbi.hwndOwner=this->m_hWnd; lpbi.pszDisplayName=str; lpbi.lpszTitle="Test"; lpbi.ulFlags=0; CoInitialize(NULL); OleInitialize(NULL); SHBrowseForFolder(&lpbi); } For some reason the call to ShBrowseForFolder crashes .

        W 1 Reply Last reply
        0
        • A act_x

          OnDisplay() { char str[MAX_PATH ]; BROWSEINFOA lpbi; lpbi.hwndOwner=this->m_hWnd; lpbi.pszDisplayName=str; lpbi.lpszTitle="Test"; lpbi.ulFlags=0; CoInitialize(NULL); OleInitialize(NULL); SHBrowseForFolder(&lpbi); } For some reason the call to ShBrowseForFolder crashes .

          W Offline
          W Offline
          wb
          wrote on last edited by
          #4

          I found something like this, and it works for me...

          CoInitialize(0);
          BROWSEINFO bi;
          char cc[MAX_PATH];
          bi.hwndOwner=m_hWnd;
          bi.pidlRoot=0;
          bi.pszDisplayName=cc;
          bi.lpszTitle="";
          bi.ulFlags =0;
          bi.lpfn =0;
          bi.iImage=0;

          LPITEMIDLIST p;
          p=SHBrowseForFolder(&bi);

          if(!p)
          return;

          SHGetPathFromIDList(p,cc);

          SetDlgItemText(IDC_E_PATH,cc);

          IMalloc *pm;
          SHGetMalloc(&pm);
          pm->Free(p);

          A 1 Reply Last reply
          0
          • W wb

            I found something like this, and it works for me...

            CoInitialize(0);
            BROWSEINFO bi;
            char cc[MAX_PATH];
            bi.hwndOwner=m_hWnd;
            bi.pidlRoot=0;
            bi.pszDisplayName=cc;
            bi.lpszTitle="";
            bi.ulFlags =0;
            bi.lpfn =0;
            bi.iImage=0;

            LPITEMIDLIST p;
            p=SHBrowseForFolder(&bi);

            if(!p)
            return;

            SHGetPathFromIDList(p,cc);

            SetDlgItemText(IDC_E_PATH,cc);

            IMalloc *pm;
            SHGetMalloc(&pm);
            pm->Free(p);

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Thank you for the help I wasnt doing this bi.pidlRoot=0; hence the crash . Another question using LPITEMIDLIST p how do I get the FilePath ?

            1 Reply Last reply
            0
            • A act_x

              In one of my apps I need to present the user with a Directory structure (like in windows explorer) . I want to allow the user to only select the folder . Based on this I need to do further actions . Can the usual CFileDialog class serve this purpose ? .

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              act_x wrote: Can the usual CFileDialog class serve this purpose ? . Yes, but SHBrowseForFolder() is going to be easier.


              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups