|
-
December 16th, 2003, 09:31 AM
#1
Make CFileDialog fixed to one Folder
Hi Gurus,
Is it possible to make the CFileDialog fixed to one directory. The user should not be able to change the directory by any button. It only shows the content of the m_ofn.lpstrInitialDir.
Any suggestions guys. One more idea is to build a Dialog which does the similar thing but i want to reuse the class and not build something new.
thanks in advance
cheers
sumits
---------------------------------------------------------------------------------
Live as if U would Die tommorow and Learn as if U will Live Forever...
Live Life the Fullest!!!
----------------------------------------------------------------------------------
-
December 16th, 2003, 09:37 AM
#2
maybe the following flag will help?
OFN_NOCHANGEDIR
Restores the current directory to its original value if the user changed the directory while searching for files.
-
December 16th, 2003, 09:49 AM
#3
No Pal
Hi myth,
I have already tried that. that only allows the CFileDialog to come back to initialDirectory after a DoModal is performed. Its about the saving the global path. which will not be changed by this file dialog.
Any more ways guys...
thanks myth for the prompt reply.
regards
sumits
---------------------------------------------------------------------------------
Live as if U would Die tommorow and Learn as if U will Live Forever...
Live Life the Fullest!!!
----------------------------------------------------------------------------------
-
December 16th, 2003, 10:52 AM
#4
Two things you could try:
1. Handle the OnFolderChange message (WM_NOTIFY CDN_FOLDERCHANGE message.). this one would be kinda rough... (behavior wise)
2. Use the OFN_ENABLETEMPLATE flag in the OPENFILENAME structure and pass your own dialog template. I've never done this so can't guarantee it will work.
If all else fails, write your own dialog!
-
December 16th, 2003, 11:25 AM
#5
I did some tests. I thought that indeed handling the message WM_NOTIFY CDN_FOLDERCHANGE then u can make changes. I derived a class from the CFileDialog called CMyFileDialog, and there I override the OnFolderChange() function. I inserted a single line in it:
Code:
strcpy(this->m_ofn.lpstrFile,"C:\\TEMP");
, where
C:\TEMP is the folder that u want to be fixed. It is not working properly, because u can change the folders however. The best idea is still the one of building your own file open dialog box, OR, in the hook function that u can provide (see parameter lpfnHook of the OPENFILENAME structure), u have to handle all the messages sent by the dialog controls (list,buttons etc.,), and modify their behaviour.
RATE ME OR HATE ME
-
December 16th, 2003, 11:38 AM
#6
Umm.. i know of those
Hi thanks
I know of those but the message handler only returns it after folder has been changed.
I want to access the private member of the CFileDialog.. which may contain the ListBox File path.
something like that. .am not sure..
thanks
sumits
---------------------------------------------------------------------------------
Live as if U would Die tommorow and Learn as if U will Live Forever...
Live Life the Fullest!!!
----------------------------------------------------------------------------------
-
December 16th, 2003, 12:00 PM
#7
-
December 16th, 2003, 11:41 PM
#8
Thanks
Hi kirants...
Thanks for the solution but probably i will not be able to use that. I think it is better to make a dialog with similar feature and read all File content with the right filter. In that i will not allow it to move up the folder.
But the solution is really interesting. The problem i have is that it is a not a fool proof solution. It should not fail in any place.
thanks a lot for the help
regards
sumits
Last edited by sumits; December 16th, 2003 at 11:55 PM.
---------------------------------------------------------------------------------
Live as if U would Die tommorow and Learn as if U will Live Forever...
Live Life the Fullest!!!
----------------------------------------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|