Link to home
Start Free TrialLog in
Avatar of reichj
reichj

asked on

CFileDialog does not handle long extensions

I would like to save files with extensions longer than three chars,  This is done by MFC with serialization.
When using CFileDialog (or for that matter the GetSaveFileName() API) extensions are limited to three chars due to the OPENFILENAME struct. What's up with that? (dont answer)
It is possible to use the SaveAs dialog and then append my own extension, but then I wont get the benefit of OFN_OVERWRITEPROMPT.
Any solutions?

Thanks.
Jeff
Avatar of chensu
chensu
Flag of Canada image

It is not limited to three chars. Do you use the flag OFN_EXPLORER or OFN_LONGNAMES?
Avatar of reichj
reichj

ASKER

chensu,

I have tried both of those proir to posting the question.  Do you have a test app with CFileDialog or GetSaveFileName() working with long extensions? Maybe I'm doing something wrong but I've been through the OPENFILENAME doc's and aggree that OFN_LONGNAMES should produce the desired result, but it doesnt.
The doc's do say this about lpstrDefExt : "append this extension to the filename if the user fails to type an extension. This string can be any length, but only the first three characters are appended".
If you have a code snipet which works please post it.

Thanks,
Jeff
What function do you use to get the filename from CFileDialog... GetPathName() ?

Do you call GetFileExt() to get the extension?
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of reichj

ASKER

Mike,

Is this bug documented? Is there an MSDN Q# or search keyword to find it?

So I guess to use >3 char extenstions I have to

(a) Not use OFN_OVERWRITEPROMPT
(b) append my own extension to the pathname, and
(c) Do my own overwrite protection (and dialog). Of course if the user doesnt want to overwrite I have to bring up the CFileDialog again to allow another filename selection.

or

Just overwrite without telling the user,  which generally does not go over very well.

Jeff


I don't know if it is documented; I don't think it is.

B ekiM