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. Change Dir inside CFileDialog

Change Dir inside CFileDialog

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
28 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.
  • V Victor Nijegorodov

    I guess that UpdateData has nothing to do with what you are trying to achieve. Could you post your actual code?

    U Offline
    U Offline
    User 401087
    wrote on last edited by
    #21

    void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles"}; SetCurrentDirectory(szPath); } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles"}; SetCurrentDirectory(szPath2); } Invalidate(); UpdateData(false); // Here I want refresh the CFileDialog with the new filter and path }

    I Try, but I'm not sure :))

    V 2 Replies Last reply
    0
    • U User 401087

      void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles"}; SetCurrentDirectory(szPath); } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles"}; SetCurrentDirectory(szPath2); } Invalidate(); UpdateData(false); // Here I want refresh the CFileDialog with the new filter and path }

      I Try, but I'm not sure :))

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #22

      No, this code won't work. SetCurrentDirectory just sets the current directory. It cannot change the folder selection within the CFileDialog. You have to find the possibility to change the folder selection within the CFileDialog control(s)!

      U 1 Reply Last reply
      0
      • V Victor Nijegorodov

        No, this code won't work. SetCurrentDirectory just sets the current directory. It cannot change the folder selection within the CFileDialog. You have to find the possibility to change the folder selection within the CFileDialog control(s)!

        U Offline
        U Offline
        User 401087
        wrote on last edited by
        #23

        ok, and what are these controls? can you send me an example code? Thank you

        I Try, but I'm not sure :))

        1 Reply Last reply
        0
        • U User 401087

          void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles"}; SetCurrentDirectory(szPath); } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles"}; SetCurrentDirectory(szPath2); } Invalidate(); UpdateData(false); // Here I want refresh the CFileDialog with the new filter and path }

          I Try, but I'm not sure :))

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #24

          Try instead to overwrite the m_ofn member lpstrFile to contain the full folder path, either "c:\\DocFiles" or "c:\\TxtFiles".

          U 1 Reply Last reply
          0
          • V Victor Nijegorodov

            Try instead to overwrite the m_ofn member lpstrFile to contain the full folder path, either "c:\\DocFiles" or "c:\\TxtFiles".

            U Offline
            U Offline
            User 401087
            wrote on last edited by
            #25

            sorry, it doesn't work :(

            I Try, but I'm not sure :))

            V 1 Reply Last reply
            0
            • U User 401087

              sorry, it doesn't work :(

              I Try, but I'm not sure :))

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #26

              Could you post your implementation?

              U 2 Replies Last reply
              0
              • V Victor Nijegorodov

                Could you post your implementation?

                U Offline
                U Offline
                User 401087
                wrote on last edited by
                #27

                I try: void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles"}; SetCurrentDirectory(szPath); m_ofn.lpstrFile=szPath; } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles"}; SetCurrentDirectory(szPath2); m_ofn.lpstrFile=szPath2; } Invalidate(); UpdateData(false); } and void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles\\file.doc"}; SetCurrentDirectory(szPath); m_ofn.lpstrFile=szPath; } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles\\file.txt"}; SetCurrentDirectory(szPath2); m_ofn.lpstrFile=szPath2; } Invalidate(); UpdateData(false); } but don't work. N.B. the file.txt and file.doc are existing files on the disk.

                I Try, but I'm not sure :))

                1 Reply Last reply
                0
                • V Victor Nijegorodov

                  Could you post your implementation?

                  U Offline
                  U Offline
                  User 401087
                  wrote on last edited by
                  #28

                  I try 2 solution: void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles"}; SetCurrentDirectory(szPath); m_ofn.lpstrFile=szPath; } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles"}; SetCurrentDirectory(szPath2); m_ofn.lpstrFile=szPath2; } Invalidate(); UpdateData(false); } and void MyClass::OnTypeChange() { if(m_ofn.nFilterIndex==2){ // .doc char szPath [MAX_PATH] = {"c:\\DocFiles\\file.doc"}; //SetCurrentDirectory(szPath); m_ofn.lpstrFile=szPath; } else { // .txt char szPath2 [MAX_PATH] = {"c:\\TxtFiles\\file.txt"}; //SetCurrentDirectory(szPath2); m_ofn.lpstrFile=szPath2; } Invalidate(); UpdateData(false); } But don't work. N.B.: c:\DocFiles\file.doc and c:\TxtFiles\file.txt are existing files on the disk.

                  I Try, but I'm not sure :))

                  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