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. help

help

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 6 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.
  • S Offline
    S Offline
    SnaKeBeD
    wrote on last edited by
    #1

    Can anybody help me in solving my problem..... i am using a CFileDialog class for accessing multiple files through browse.But depending up on the file path length the number of files that are getting selected varied Is there anyway in solving this problem(i need to select a maximum of 20 files). CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK |OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*");:doh:

    ||SnAkeBed||

    R S R P 4 Replies Last reply
    0
    • S SnaKeBeD

      Can anybody help me in solving my problem..... i am using a CFileDialog class for accessing multiple files through browse.But depending up on the file path length the number of files that are getting selected varied Is there anyway in solving this problem(i need to select a maximum of 20 files). CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK |OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*");:doh:

      ||SnAkeBed||

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      I htink you need to change the buffer size used for the returned filenames if the OFM struct: It has to be large enough to contain all the full paths etc for all the files selected. So you probably need _MAX_PATH * 20 in length: // copied and pasted from an app char buffer[4096] = ""; // filename(s) buffer dlg.m_ofn.nMaxFile = 4096; dlg.m_ofn.lpstrFile = buffer;

      If you vote me down, my score will only get lower

      1 Reply Last reply
      0
      • S SnaKeBeD

        Can anybody help me in solving my problem..... i am using a CFileDialog class for accessing multiple files through browse.But depending up on the file path length the number of files that are getting selected varied Is there anyway in solving this problem(i need to select a maximum of 20 files). CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK |OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*");:doh:

        ||SnAkeBed||

        S Offline
        S Offline
        SnaKeBeD
        wrote on last edited by
        #3

        i tried that its generating error... this is my exact code obBrowse() { int count=0; CSting filename[256]; CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK|OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*"); POSITION file=fileDialog.GetStartPosition(); if(fileDialog.DoModal==IDOK) //this is where error is generating if i select more files... (for example 20) { UINT count=0; POSITION pos=fileDialog.GetStartPosition(); while(pos) { fileDialog.GetNextPathPosition(pos); ++count; } while(file!=NULL) { fileName[count]=fileDialog.GetNextPathName(file); } } } can you tell me where

        ||SnAkeBed||

        D R 3 Replies Last reply
        0
        • S SnaKeBeD

          Can anybody help me in solving my problem..... i am using a CFileDialog class for accessing multiple files through browse.But depending up on the file path length the number of files that are getting selected varied Is there anyway in solving this problem(i need to select a maximum of 20 files). CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK |OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*");:doh:

          ||SnAkeBed||

          R Offline
          R Offline
          Russell
          wrote on last edited by
          #4

          I use this code: CFileDialog dlgFile(TRUE, "txt", NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT, YOURFILETYPEFILTER, NULL, 0); CString ResourceString="Select file(s)"; TCHAR szFile[IMPORT_MAX_PATH_LENGTH]; _tcscpy(szFile, ResourceString); dlgFile.m_ofn.lpstrFile=szFile; dlgFile.m_ofn.nMaxFile=IMPORT_MAX_PATH_LENGTH; if(dlgFile.DoModal()!=IDOK) return FALSE;


          Russell

          T 1 Reply Last reply
          0
          • S SnaKeBeD

            i tried that its generating error... this is my exact code obBrowse() { int count=0; CSting filename[256]; CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK|OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*"); POSITION file=fileDialog.GetStartPosition(); if(fileDialog.DoModal==IDOK) //this is where error is generating if i select more files... (for example 20) { UINT count=0; POSITION pos=fileDialog.GetStartPosition(); while(pos) { fileDialog.GetNextPathPosition(pos); ++count; } while(file!=NULL) { fileName[count]=fileDialog.GetNextPathName(file); } } } can you tell me where

            ||SnAkeBed||

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

            SnaKeBeD wrote:

            if(fileDialog.DoModal==IDOK)

            How did you even get this to compile correctly, or is it not a true copy/paste?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • S SnaKeBeD

              i tried that its generating error... this is my exact code obBrowse() { int count=0; CSting filename[256]; CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK|OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*"); POSITION file=fileDialog.GetStartPosition(); if(fileDialog.DoModal==IDOK) //this is where error is generating if i select more files... (for example 20) { UINT count=0; POSITION pos=fileDialog.GetStartPosition(); while(pos) { fileDialog.GetNextPathPosition(pos); ++count; } while(file!=NULL) { fileName[count]=fileDialog.GetNextPathName(file); } } } can you tell me where

              ||SnAkeBed||

              R Offline
              R Offline
              Russell
              wrote on last edited by
              #6

              SnaKeBeD wrote:

              CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK|OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*"); POSITION file=fileDialog.GetStartPosition();

              mmmm...is it too soon to call GetStartPosition()?:~


              Russell

              1 Reply Last reply
              0
              • S SnaKeBeD

                i tried that its generating error... this is my exact code obBrowse() { int count=0; CSting filename[256]; CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK|OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*"); POSITION file=fileDialog.GetStartPosition(); if(fileDialog.DoModal==IDOK) //this is where error is generating if i select more files... (for example 20) { UINT count=0; POSITION pos=fileDialog.GetStartPosition(); while(pos) { fileDialog.GetNextPathPosition(pos); ++count; } while(file!=NULL) { fileName[count]=fileDialog.GetNextPathName(file); } } } can you tell me where

                ||SnAkeBed||

                R Offline
                R Offline
                Russell
                wrote on last edited by
                #7

                SnaKeBeD wrote:

                if(fileDialog.DoModal==IDOK)

                :omg::wtf::omg: what about if(fileDialog.DoModal**()**==IDOK)


                Russell

                1 Reply Last reply
                0
                • R Russell

                  I use this code: CFileDialog dlgFile(TRUE, "txt", NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT, YOURFILETYPEFILTER, NULL, 0); CString ResourceString="Select file(s)"; TCHAR szFile[IMPORT_MAX_PATH_LENGTH]; _tcscpy(szFile, ResourceString); dlgFile.m_ofn.lpstrFile=szFile; dlgFile.m_ofn.nMaxFile=IMPORT_MAX_PATH_LENGTH; if(dlgFile.DoModal()!=IDOK) return FALSE;


                  Russell

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  _Russell_ wrote:

                  CString ResourceString="Select file(s)"; TCHAR szFile[IMPORT_MAX_PATH_LENGTH]; _tcscpy(szFile, ResourceString);

                  you could have factorized this anyway :

                  TCHAR szFile[IMPORT_MAX_PATH_LENGTH] = _T("Select file(s)");

                  ;P


                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  R 1 Reply Last reply
                  0
                  • T toxcct

                    _Russell_ wrote:

                    CString ResourceString="Select file(s)"; TCHAR szFile[IMPORT_MAX_PATH_LENGTH]; _tcscpy(szFile, ResourceString);

                    you could have factorized this anyway :

                    TCHAR szFile[IMPORT_MAX_PATH_LENGTH] = _T("Select file(s)");

                    ;P


                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    R Offline
                    R Offline
                    Russell
                    wrote on last edited by
                    #9

                    my code was more complex: ;P

                    CString ResourceString=""; ResourceString.LoadString(IDS_STR_SELECTFILENAME);

                    ...thanks anyway for the right lesson ;):-D


                    Russell

                    1 Reply Last reply
                    0
                    • S SnaKeBeD

                      Can anybody help me in solving my problem..... i am using a CFileDialog class for accessing multiple files through browse.But depending up on the file path length the number of files that are getting selected varied Is there anyway in solving this problem(i need to select a maximum of 20 files). CFileDialog fileDialog(true,null,null,OFN_MULTISELECT | OFN_NODEREFERNCELINK |OFN_EXPLORER ,"Excel File(*.xls)|*.xls|AllTypes(*.*)|*.*");:doh:

                      ||SnAkeBed||

                      P Offline
                      P Offline
                      PJ Arends
                      wrote on last edited by
                      #10

                      http://www.codeproject.com/dialog/pja_multiselect.asp[^]


                      You may be right I may be crazy -- Billy Joel -- 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