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. How to let user choose a directory?

How to let user choose a directory?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 4 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.
  • R Offline
    R Offline
    Raphael Kindt
    wrote on last edited by
    #1

    Hi world, I want a simple dialog box (like CFileDialog) who let the user choose only a directory (not a file)... Can somebody give me a simple example which does that? Thanks in advance... Hello World!!! :) from Raphaël

    J D B 3 Replies Last reply
    0
    • R Raphael Kindt

      Hi world, I want a simple dialog box (like CFileDialog) who let the user choose only a directory (not a file)... Can somebody give me a simple example which does that? Thanks in advance... Hello World!!! :) from Raphaël

      J Offline
      J Offline
      Joan M
      wrote on last edited by
      #2

      There are lots of samples here in CP... http://www.codeproject.com/dialog/#Windows%20Common%20dialogs[^] for example... Hope this helps.

      R 1 Reply Last reply
      0
      • J Joan M

        There are lots of samples here in CP... http://www.codeproject.com/dialog/#Windows%20Common%20dialogs[^] for example... Hope this helps.

        R Offline
        R Offline
        Raphael Kindt
        wrote on last edited by
        #3

        I would have to look in Code Project first, sorry... Hello World!!! :) from Raphaël

        J 1 Reply Last reply
        0
        • R Raphael Kindt

          I would have to look in Code Project first, sorry... Hello World!!! :) from Raphaël

          J Offline
          J Offline
          Joan M
          wrote on last edited by
          #4

          Don't worry! ;)

          1 Reply Last reply
          0
          • R Raphael Kindt

            Hi world, I want a simple dialog box (like CFileDialog) who let the user choose only a directory (not a file)... Can somebody give me a simple example which does that? Thanks in advance... Hello World!!! :) from Raphaël

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

            SHBrowseForFolder()

            1 Reply Last reply
            0
            • R Raphael Kindt

              Hi world, I want a simple dialog box (like CFileDialog) who let the user choose only a directory (not a file)... Can somebody give me a simple example which does that? Thanks in advance... Hello World!!! :) from Raphaël

              B Offline
              B Offline
              basementman
              wrote on last edited by
              #6

              The following sample browses for a directory: void BrowseForDir() { char caPathName[MAX_PATH]; caPathName[0] = 0; GetDlgItemText(IDC_MYCTRL_TO_BACKFILL,caPathName,MAX_PATH); BROWSEINFO sBI; memset(&sBI,0,sizeof(BROWSEINFO)); sBI.hwndOwner = m_hWnd; sBI.pidlRoot = NULL; sBI.pszDisplayName = caPathName; sBI.lpszTitle = "Select the folder that contains the desired files"; sBI.ulFlags = BIF_RETURNONLYFSDIRS; sBI.lpfn = NULL; LPITEMIDLIST pidl = SHBrowseForFolder(&sBI); if (pidl) { SHGetPathFromIDList(pidl,caPathName); SetDlgItemText(IDC_MYCTRL_TO_BACKFILL,caPathName); GotoDlgCtrl(GetDlgItem(IDC_MYCTRL_TO_BACKFILL)); } }  onwards and upwards...

              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