CFileDialog
-
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
-
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
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
-
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
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:
-
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
before domodal() use SetCurrentDirectory()