How to make CFileDialog synchronize the displayed filename with the selected extension?
Posted
by RobH
on Stack Overflow
See other posts from Stack Overflow
or by RobH
Published on 2009-12-14T19:28:54Z
Indexed on
2010/04/02
2:03 UTC
Read the original article
Hit count: 404
We have a class that derives from CFileDialog that overrides the OnTypeChange() method to allow it to change the filename to keep it in synch with the selected extension whenever the user selects a new extension from the filter combobox. (Our filters are set to contain only one extension per filter entry.) Unfortunately, the way we are doing this seems to have been broken by the Vista style dialogue. (We were using SetControlText() to set the filename edit box to the filename with the newly selected extension, but the control ID seems to be different for the Vista style dialogue, and the one that I found using Spy++ works just as well as the old ID (i.e., it doesn't)..)
Is there a better way to tell the CFileDialog object to update the filename field to use the new extension when the user selects a new filter? It has to work with the old XP style dialogue as well.
Failing that, how to I force the use of the XP style dialogue so that I get my functionality back without the dialogue crashing on me? (I'd rather not go that route if at all possible.) I've found a way to get it to fall back to the XP style. I still want to get the new style dialogue to do what I want though.
© Stack Overflow or respective owner