How to set document file extension?
-
Hi, I am using serialize to write out my MFC application document data. I want to have names in the file dialog post-fixed with a file extension, like "binky.dfg" (.dfg is the file extension). I understand I need to call CWinApp::RegisterShellFileTypes(...). However, this will only work if I set the appropriate string for the file extension in my CSingleDocTemplate. I browsed around and found CSingleDocTemplate.GetDocString(...). This will let me read what the file extension is for my document. But how do I set a file extension? There is no SetDocString(...). It looks like the CSingleDocTemplate members I am interested in are some/all of regFileTypeId, regFileTypeName, filterExt, or filterName. I'm not sure which one I should be working with. Also, these are member variables of the class. Shouldn't I be not touching these directly? Rather, shouldn't I be using some class member functions to do the work? Help? :doh: Max
-
Hi, I am using serialize to write out my MFC application document data. I want to have names in the file dialog post-fixed with a file extension, like "binky.dfg" (.dfg is the file extension). I understand I need to call CWinApp::RegisterShellFileTypes(...). However, this will only work if I set the appropriate string for the file extension in my CSingleDocTemplate. I browsed around and found CSingleDocTemplate.GetDocString(...). This will let me read what the file extension is for my document. But how do I set a file extension? There is no SetDocString(...). It looks like the CSingleDocTemplate members I am interested in are some/all of regFileTypeId, regFileTypeName, filterExt, or filterName. I'm not sure which one I should be working with. Also, these are member variables of the class. Shouldn't I be not touching these directly? Rather, shouldn't I be using some class member functions to do the work? Help? :doh: Max
If you are using
CFileDialog
then look at the second parameter lpszDefExt of the constructorCFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );
Regards, Paresh.