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

CFileDialog

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • H Offline
    H Offline
    Henri
    wrote on last edited by
    #1

    Is there any way to prevent CFileDialog from changing forlders ? Or at least to always default to a given folder. I want to use CFileDialog just to look at files in one folder and one folder only. a) can I disable/remove the folder choices from the CFileDialog window. b) if not can I force CFileDialog to only look in one folder ? c) even if user changes folder, when done can I force CFileDialog next time to go back to my given folder ? I could not find an option to disable CFileDialog browsing, so I tried to force it to always look at my folder only, like so. CFileDialog dlg(TRUE, "pfl", name, ..., ... | OFN_NOCHANGEDIR) SetCurrentDirectory ("My Fixed Choice"); dlg.m_ofn.lpstrInitialDir = "My Fixed Choice"; if (dlg.DoModal() == IDOK) { } If the user changes folders, it next time goes back to that folder and ignores the above ???? Thanks Henri

    D M S 3 Replies Last reply
    0
    • H Henri

      Is there any way to prevent CFileDialog from changing forlders ? Or at least to always default to a given folder. I want to use CFileDialog just to look at files in one folder and one folder only. a) can I disable/remove the folder choices from the CFileDialog window. b) if not can I force CFileDialog to only look in one folder ? c) even if user changes folder, when done can I force CFileDialog next time to go back to my given folder ? I could not find an option to disable CFileDialog browsing, so I tried to force it to always look at my folder only, like so. CFileDialog dlg(TRUE, "pfl", name, ..., ... | OFN_NOCHANGEDIR) SetCurrentDirectory ("My Fixed Choice"); dlg.m_ofn.lpstrInitialDir = "My Fixed Choice"; if (dlg.DoModal() == IDOK) { } If the user changes folders, it next time goes back to that folder and ignores the above ???? Thanks Henri

      D Offline
      D Offline
      Doc Lobster
      wrote on last edited by
      #2

      Hi Henri, I was faced with a similar question some time ago and decided to use CFileFind(er?) and put the results into a ListBox. That seemed to be the simplest approach because I only wanted to select a file from a list anyway. Regards, Andreas

      1 Reply Last reply
      0
      • H Henri

        Is there any way to prevent CFileDialog from changing forlders ? Or at least to always default to a given folder. I want to use CFileDialog just to look at files in one folder and one folder only. a) can I disable/remove the folder choices from the CFileDialog window. b) if not can I force CFileDialog to only look in one folder ? c) even if user changes folder, when done can I force CFileDialog next time to go back to my given folder ? I could not find an option to disable CFileDialog browsing, so I tried to force it to always look at my folder only, like so. CFileDialog dlg(TRUE, "pfl", name, ..., ... | OFN_NOCHANGEDIR) SetCurrentDirectory ("My Fixed Choice"); dlg.m_ofn.lpstrInitialDir = "My Fixed Choice"; if (dlg.DoModal() == IDOK) { } If the user changes folders, it next time goes back to that folder and ignores the above ???? Thanks Henri

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        There used to be a OFN_NOCHANGEDIR flag you could use, but it is no longer supported. Check the (current) docs for the OPENFILENAME.lpstrInitialDir member and see if any of the algorithms the system uses to set the initial directory apply to you (it varies by OS). Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        1 Reply Last reply
        0
        • H Henri

          Is there any way to prevent CFileDialog from changing forlders ? Or at least to always default to a given folder. I want to use CFileDialog just to look at files in one folder and one folder only. a) can I disable/remove the folder choices from the CFileDialog window. b) if not can I force CFileDialog to only look in one folder ? c) even if user changes folder, when done can I force CFileDialog next time to go back to my given folder ? I could not find an option to disable CFileDialog browsing, so I tried to force it to always look at my folder only, like so. CFileDialog dlg(TRUE, "pfl", name, ..., ... | OFN_NOCHANGEDIR) SetCurrentDirectory ("My Fixed Choice"); dlg.m_ofn.lpstrInitialDir = "My Fixed Choice"; if (dlg.DoModal() == IDOK) { } If the user changes folders, it next time goes back to that folder and ignores the above ???? Thanks Henri

          S Offline
          S Offline
          Sameerkumar Namdeo
          wrote on last edited by
          #4

          before domodal() use SetCurrentDirectory()

          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