mco
asked on
In CFileDialog file name appears without extension
The following constructor:
CFileDialog d(FALSE, NULL, "bb.txt", NULL);
causes the file dialog to appear with "bb" as the file name (although pressing 'Save' and GetPathName , retrieve the full name with the extension).
This may cause confusion to the user.
I found out that this is happens because only when the "hide file extension for known file types" bit is checked in the folder options settings of the Windows Explorer.
Question: How can I force the file name to appear with the extension, regardless of the folder options settings the user chose for his/her environment?
CFileDialog d(FALSE, NULL, "bb.txt", NULL);
causes the file dialog to appear with "bb" as the file name (although pressing 'Save' and GetPathName , retrieve the full name with the extension).
This may cause confusion to the user.
I found out that this is happens because only when the "hide file extension for known file types" bit is checked in the folder options settings of the Windows Explorer.
Question: How can I force the file name to appear with the extension, regardless of the folder options settings the user chose for his/her environment?
Hi,
If u want to do it programatically, then u need to set the values of some registry keys which depends on the OS. Say for example for Win-98
HKEY_CURRENT_USER\\SOFTWAR E\\Microso ft\\Window s\\Current Version\\E xplorer\\A dvanced
and
HKEY_LOCAL_MACHINE\\SOFTWA RE\\Micros oft\\Windo ws\\Curren tVersion\\ Explorer\\ Advanced
value should be set to 0(zero) to disable that and should be set to 1 to enable it.
This will be different key for NT ofcourse!!!
But, I dont suggest this method as it is complex and changes some global settings.
Try it out.
VinExpert
If u want to do it programatically, then u need to set the values of some registry keys which depends on the OS. Say for example for Win-98
HKEY_CURRENT_USER\\SOFTWAR
and
HKEY_LOCAL_MACHINE\\SOFTWA
value should be set to 0(zero) to disable that and should be set to 1 to enable it.
This will be different key for NT ofcourse!!!
But, I dont suggest this method as it is complex and changes some global settings.
Try it out.
VinExpert
ASKER
Regarding the first comment, I do not have a filter and do not want to put one in. The ".txt" in the code was only an example.
Regarding the second comment, not only is it complex and OS dependent, it is dangerous as you can change the users settings.
Is this problem considered a bug by MS at all?
Regarding the second comment, not only is it complex and OS dependent, it is dangerous as you can change the users settings.
Is this problem considered a bug by MS at all?
Hi,
Yes, thats why I expicitly told that, I wont suggest second method.
I guess MS thinks it as feature rather than a bug!!!
VinExpert
Yes, thats why I expicitly told that, I wont suggest second method.
I guess MS thinks it as feature rather than a bug!!!
VinExpert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi mco,
Do you have any additional questions? Do any comments need clarification? Does it matter to you that I spent a lot of time working on this?
-- Dan
Do you have any additional questions? Do any comments need clarification? Does it matter to you that I spent a lot of time working on this?
-- Dan
ASKER
Dear Dan,
I appreciate very much your reply. Just today I saw both it and this last comment. Due to unexpected personal reasons I am not at my computer often, and have not gone back to my programming.
I assure you that I will check out your suggestion, and if it works, you will be fully awarded.
I apologize, but it may take some time yet, till I get back to work.
I appreciate very much your reply. Just today I saw both it and this last comment. Due to unexpected personal reasons I am not at my computer often, and have not gone back to my programming.
I assure you that I will check out your suggestion, and if it works, you will be fully awarded.
I apologize, but it may take some time yet, till I get back to work.
If I am getting ur problem correctly, when u execute ur code, the 'File Name' will have just bb. And that may cause user confusion. So u want to display it as bb.txt. right?
For that there is a work around. Usually we will set the filter to the CFileDialog object and hence the file type will be displayed in the 'Save as type' field. Then that will specify to the user that, file will be saved in text format. To do that, use the following code:
static char BASED_CODE szFilt[] = "File (*.txt)|*.txt||";
CFileDialog dlg(FALSE, NULL,"bb.txt",NULL, szFilt);
dlg.DoModal();
Try it out.
VinExpert