设为首页 加入收藏

TOP

VC++环境下多文档模板应用程序开发(带源码)(二)
2015-07-24 06:37:25 来源: 作者: 【 】 浏览:68
Tags:环境 文档 模板 应用 程序开发 源码
g;

在应用程序的派生类的头部添加以下代码:

#include "BubDoc.h"
#include "BubFrame.h"
#include "BubView.h"

并使用Class Wizard 创建ID_FILE_NEW_BUB ,ID_FILE_OPEN_BUB和ID_FILE_NEW_TXT的消息响应函数。

响应函数的代码如下:

void CMultiDoctempApp::OnFileNewTxt()
{
POSITION curTemplatePos = GetFirstDocTemplatePosition();
while (curTemplatePos != NULL)
{
CDocTemplate * curTemplate = GetNextDocTemplate(curTemplatePos);
CString str;
curTemplate->GetDocString(str,CDocTemplate::docName);
if (str == _T("Txt"))
{
curTemplate->OpenDocumentFile(NULL);
return;
}
}
AfxMessageBox("NO TXTTEMPALTE!");
}

void CMultiDoctempApp::OnFileNewBub()
{
POSITION curTemplatePos = GetFirstDocTemplatePosition();
while (curTemplatePos != NULL)
{
CDocTemplate * curTemplate = GetNextDocTemplate(curTemplatePos);
CString str;
curTemplate->GetDocString(str,CDocTemplate::docName);
if (str == _T("Bub"))
{
curTemplate->OpenDocumentFile(NULL);
return;
}
}
AfxMessageBox("NO BUBTEMPALTE!");
}

void CMultiDoctempApp::OnFileOpenBub()
{
POSITION curTemplatePos = GetFirstDocTemplatePosition();
while (curTemplatePos != NULL)
{
CDocTemplate * curTemplate = GetNextDocTemplate(curTemplatePos);
CString str;
curTemplate->GetDocString(str,CDocTemplate::docName);
if (str == _T("Bub"))
{
CFileDialog dlg(true);
if (dlg.DoModal() == IDOK)
{
CString path = dlg.GetPathName();
curTemplate->OpenDocumentFile(path);
}
return;
}
}
AfxMessageBox("NO TXTTEMPALTE!");
}

以上的介绍就是VC++环境下多文档模板应用程序开发的一个小例子。希望能够帮助到大家。

该篇文章参考知网上的论文资料本人总结所得。
源码的下载地址:http://download.csdn.net/my




首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HUNNU Contest 找数字2 下一篇[BZOJ 1084][SCOI2005]最大子矩阵

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: