If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to get the Encoder drop down in a File Save dialog ?

I need to have a user option to save a file as either UTF-8 or UTF-16, such as NotePad does. But I cannot figure out how to get the CFileDialog to display the Encoder drop down selector. Does anyone know how to do this. I am aware the since VISTA there is another API that one can use, but that API is not compatible with pre-VISTA OS 's. Thanks.

Re: How to get the Encoder drop down in a File Save dialog ?

I need something that works for pre-VISTA, VISTA, and post-VISTA as well. I cannot get it to work after reviewing the Marius Bancila's blog and the M$ websites. Really need a coded example. For one thing, there is no explanation of where the 'dialog template' comes from, whether or not they pre-exist somewhere, can be downloaded, or need to be created from scratch (and if so, how?). Where does Marius pull out "DIALOG_PREVIEW"? I can find no reference to it anywhere. Furthermore, while Marius' code compiles on my Win2k / VS 2010 machine, it doesn't work properly.

The lines that are commented out, if left in, result in failure of the dialog to open altogether (Win2k) but doesn't crash or produce any error message. On Win7 (64-bit) machine, it compiles and runs with those lines but produces behaviour unlike that predicted by Marius.

Re: How to get the Encoder drop down in a File Save dialog ?

You make your own container template and compile/link it in the resources of your exe.

Exactly how do you do this? Do you mean create a new dialog resource in the resource editor and populate it with all the controls that you need, then somehow link it to the VS 2010 MFC app? Or is there some other method you are referring to. I like the way everyone throws around this 'Well, just create your own dialog template...' and fails to go on to explain what they mean by this. Even the google sites that I've visited have failed to illuminate this puzzle for me. I understand how one sets up the flags in the CFileDialog initialization so that a dialog template can be used. But from there on I'm lost. And Marius' oft quoted blog does not refer to an Encoding Dropdown box anywhere that I can see.

Re: How to get the Encoder drop down in a File Save dialog ?

Originally Posted by Mike Pliam

Exactly how do you do this? Do you mean create a new dialog resource in the resource editor and populate it with all the controls that you need, then somehow link it to the VS 2010 MFC app? Or is there some other method you are referring to. I like the way everyone throws around this 'Well, just create your own dialog template...' and fails to go on to explain what they mean by this. Even the google sites that I've visited have failed to illuminate this puzzle for me. I understand how one sets up the flags in the CFileDialog initialization so that a dialog template can be used. But from there on I'm lost. And Marius' oft quoted blog does not refer to an Encoding Dropdown box anywhere that I can see.

Note that you will need to derive your own class from CFileDialog to handle CDN_INITDONE message.
When overriding its ctor just call the base class ctor passing in zero and FALSE as the very last parameters (to use the default size of OPENFILENAME struct and to avoid Vista style dialog)

Re: How to get the Encoder drop down in a File Save dialog ?

Thanks. As I suspected, rolling your own custom dialog template is no small matter. If you doubt me, take a look at the CCustomFileDialog class in the MSDN sample found at http://support.microsoft.com/kb/195034/en-us. Furthermore, this best of the sample projects that I could find (thanks Victor) doesn't work!! It compiles and runs on Win 7 (64-bit) (sans hcrtf) but selecting 'Custom Template' from the View menu and attempting to use it results in 'Attempted an unsupported operation' message box with no debug output or call stack information generated. Weird !

I think I'll give this quest up for now and wait until someone posts some modern workable project.

Re: How to get the Encoder drop down in a File Save dialog ?

Originally Posted by Mike Pliam

... It compiles and runs on Win 7 (64-bit) (sans hcrtf) but selecting 'Custom Template' from the View menu and attempting to use it results in 'Attempted an unsupported operation' message box with no debug output or call stack information generated. Weird !

I think I'll give this quest up for now and wait until someone posts some modern workable project.

Mike, did you do the following:

Originally Posted by VictorN

When overriding its ctor just call the base class ctor passing in zero and FALSE as the very last parameters (to use the default size of OPENFILENAME struct and to avoid Vista style dialog)