惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
V
Visual Studio Blog
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
IT之家
IT之家
博客园_首页
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - Franky
雷峰网
雷峰网
罗磊的独立博客
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
The Cloudflare Blog
T
Tailwind CSS Blog
B
Blog RSS Feed
H
Help Net Security
T
The Blog of Author Tim Ferriss
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
P
Palo Alto Networks Blog
I
Intezer
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
S
Securelist
J
Java Code Geeks
V
V2EX
Y
Y Combinator Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
Forbes - Security
Forbes - Security
Google Online Security Blog
Google Online Security Blog
Help Net Security
Help Net Security
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
SecWiki News
SecWiki News
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
N
News and Events Feed by Topic

博客园 - 红马天下

【原创】改造rails使支持gb2312编码 【转载】Rails使用gb2312/gbk与utf8共存的解决方案 【原创】MBCS,Unicode,UTF8以及一个用C++读写UTF8文件的工具类 【原创】Asp.Net从Windows Server 2003 32bit迁移到Windows Server 2008 64bit的找不到组件 这辈子一定要做一件有意义的事 【转载】软件缺陷管理基本概念 【转载】软件配置管理中的分支 【转载】我的Lean & Agile(精简和敏捷)经历(这才是最佳实践) 【转载】微软的管理模式真的值得吹嘘么? 【转载】负载均衡技术全攻略 【转载】MySpace的六次重构 【转载】转一篇自己的书评,关于《重构》 【转载】避免软件重建失败的三种方案 【转载】ASP.NET AJAX进度条 【转载】快速、可伸缩和流式的AJAX代理--跨域持续内容分发 给CHtmlEditView添加自定义拖拽功能IDropTargetpdwEffectDROPEFFECT_COPY ole拖放的若干tips 深入分析eXtreme Toolkit Toolbar的Command消息 在eXtreme Toolkit Pro 11.2.1中使用中文
【转载】让文档模板支持多文件扩展名
红马天下 · 2008-04-23 · via 博客园 - 红马天下

出处:How to support multiple file extensions with one document type in Visual C++ MFC applications

How to support multiple file extensions with one document type in Visual C++ MFC applications

Article ID : 198538
Last Review : November 21, 2006
Revision : 4.1

This article was previously published under Q198538

On This Page

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.

This sample implements the code required to allow registration, unregistration, file open, and file save operations in an otherwise regular MFC application. The classes touched include the following:

The CWinApp-derived class.
The undocumented CDocManager class.
A custom CFileDialog-derived class that allows transparent file operations with the newly defined CDocManagerEx.

Back to the top

MORE INFORMATION

The following files are available for download from the Microsoft Download Center:

DocMgrEx.exe (http://download.microsoft.com/download/vc60pro/sample11/1/nt4/en-us/docmgrex.exe)

NOTE: To Build this project with VS .NET, change the path in the #include of AfxImpl.h on line 472 of DocManagerEx.cpp:

Change from:
#include <.."src"afximpl.h>

To:
#include <.."src"mfc"afximpl.h>

For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 (http://support.microsoft.com/kb/119591/) How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.
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:

   DocType files (.ex1;.ex2;ex3)

The 5th substring should read as follows:

   .ex1;.ex2;.ex3

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.

Back to the top

Implementation Details

To 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.

Back to the top

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

141921 (http://support.microsoft.com/kb/141921/) How to support two file extensions per MFC document type