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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Selecting multiple files in openFIleDialog

Selecting multiple files in openFIleDialog

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
6 Posts 4 Posters 1 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.
  • B Offline
    B Offline
    BoudewijnEctor
    wrote on last edited by
    #1

    Hi there, I need to select multiple files in an openfiledialog in MFC, but I use this: CFileDialog *cfd=new CFileDialog, true, ...., NULL, OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, .... , NULL) CString x; cfd->DoModal(); x=cfd->GetPathName(); How can I convert this code to get more then one file???

    V D 2 Replies Last reply
    0
    • B BoudewijnEctor

      Hi there, I need to select multiple files in an openfiledialog in MFC, but I use this: CFileDialog *cfd=new CFileDialog, true, ...., NULL, OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, .... , NULL) CString x; cfd->DoModal(); x=cfd->GetPathName(); How can I convert this code to get more then one file???

      V Offline
      V Offline
      Vitali Halershtein
      wrote on last edited by
      #2

      Hi student :) To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile. Vitali

      B 1 Reply Last reply
      0
      • V Vitali Halershtein

        Hi student :) To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile. Vitali

        B Offline
        B Offline
        BoudewijnEctor
        wrote on last edited by
        #3

        Talik wrote: Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile. I don't understand this part (I've read it to in the MSDN); that's why I put it on CP. Can you give me some code, jsut for initializing the buffer, and filling it with those files?

        V 1 Reply Last reply
        0
        • B BoudewijnEctor

          Talik wrote: Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile. I don't understand this part (I've read it to in the MSDN); that's why I put it on CP. Can you give me some code, jsut for initializing the buffer, and filling it with those files?

          V Offline
          V Offline
          Vitali Halershtein
          wrote on last edited by
          #4

          Dear BoudewijnEctor, Look at the following link with full src code and sample: http://www.codeproject.com/dialog/PJA\_MultiSelect.asp Vitali

          PJ ArendsP 1 Reply Last reply
          0
          • B BoudewijnEctor

            Hi there, I need to select multiple files in an openfiledialog in MFC, but I use this: CFileDialog *cfd=new CFileDialog, true, ...., NULL, OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, .... , NULL) CString x; cfd->DoModal(); x=cfd->GetPathName(); How can I convert this code to get more then one file???

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

            Try these two previous discussions: http://www.codeproject.com/script/comments/forums.asp?msg=574273&forumid=1647&mode=all&userid=52727#xx573787xx http://www.codeproject.com/script/comments/forums.asp?msg=574178&forumid=1647&mode=all&userid=52727#xx573924xx

            1 Reply Last reply
            0
            • V Vitali Halershtein

              Dear BoudewijnEctor, Look at the following link with full src code and sample: http://www.codeproject.com/dialog/PJA\_MultiSelect.asp Vitali

              PJ ArendsP Offline
              PJ ArendsP Offline
              PJ Arends
              wrote on last edited by
              #6

              http://www.codeproject.com/dialog/PJA_MultiSelect.asp[^]:-D


              [

              ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

              Within you lies the power for good; Use it!

              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