The information in this article applies to:
SUMMARY
DocMgrEx.exe is a sample that shows how to support multiple extensions
associated with one document type (or template) in MFC's Doc/View
architecture.
MORE INFORMATIONThe following files are available for download from the Microsoft
Download Center. Click the file names below to download the files: http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. To change the extensions supported by different document types, or to add new document types, edit the application's string table. In the string resource associated with the document type resource ID, the fourth "\n" delimited substring should read as follows:
The 5th substring should read as follows:
NOTE: DocType is the external name of the document type; and ex1, ex2, ex3
are the extensions you want to associate with your document type.
When testing the application, you will notice its behavior is similar to DevStudio with regard to file open/save operations. For example, when trying to open a file, the user specifies only a file name (without an extension), the application will successively append the extensions from the currently active filter, trying to build the file name of an existing file. If this yields no result, the application will either tell the user that the file does not exist (if the OFN_FILEMUSTEXIST flag was specified) or it will create a new file with no extension. Saving operations are very similar. Implementation DetailsTo implement correct registration code we needed to override CDocManager::RegisterShellFileTypes().Unregistration is a bit more complicated, because the corresponding functions in CWinApp and CDocManager were not declared virtual. Therefore, we needed to implement the correct code in an override of CDocManager::UnregisterShellFileTypes(), and copy and paste the code from CWinApp::UnregisterShellFileTypes() and CWinApp::ProcessShellCommand() in our own CWinApp-derived class. To implement file operations transparently, we overrode CDocManager::DoPromptFileName() and CDocManager::OpenDocumentFile(). To minimize the number of changes, the global function MatchDocType() has been defined to replace the use of CDocTemplate::MatchDocType() member function. The new function behaves as expected when multiple extensions are provided for one document template. Additional query words: kbDSupport
Keywords : kbfile kbsample kbDocView kbMFC kbVC500 kbVC600 |
Last Reviewed: December 11, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |