在多文档应用程序中中实现多重文件编辑时,如何实现指定新建某种类型的文档? 在多文档框架中实现多重文件(不同类型的文件)编辑时,遇到了一个问题。本人做了一个能编辑文本和位图的程序,每次想新建一个文本文件时,都会弹出选择新建文件的类型的窗口,我想是应用程序不知道新建文档的类型的原因所致。请教各位,在新建文件时,如何可以使得指定生成某种类型的文档,避免每次都弹出窗口选择呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.在应用程序类中添加如下成员(个数由你的文件类型数决定) CMultiDocTemplate* m_pDocTemplate; CMultiDocTemplate* m_pDocTemplateModule;CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName)CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName)2.在应用程序类中的INSTANCE函数中把原来的"CMultiDocTemplate* pDocTemplate;"改为如下: m_pDocTemplate = new CMultiDocTemplate( IDR_CURVETYPE, RUNTIME_CLASS(CCurveDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCurveView)); AddDocTemplate(m_pDocTemplate); m_pDocTemplateModule = new CMultiDocTemplate( IDR_CURVETYPE, RUNTIME_CLASS(CModuleDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CModuleView)); AddDocTemplate(m_pDocTemplateModule);3.重载ONFILENEW,并直接返回4.在文件菜单上插入两个与你文件类型对应菜单,并添加消息映射在相应的消息映射中调用那两个成员函数5.成员函数的实现如下:CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName){ CDocument* pDoc = NULL; pDoc = m_pDocTemplateModule->OpenDocumentFile(NULL); pDoc->SetTitle("模块单元");return pDoc;}CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName){ CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL); return pDoc;} 1.在应用程序中添加如下成员(成员的个数由你的文件类型决定)CDocument* OpenCurveDocumentFile(LPCTSTR lpszFileName);CDocument* OpenModuleDocumentFile(LPCTSTR lpszFileName);CMultiDocTemplate* m_pDocTemplate;CMultiDocTemplate* m_pDocTemplateModule;2.上面两个函数的实现如下:CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName){ CDocument* pDoc = NULL; pDoc = m_pDocTemplateModule->OpenDocumentFile(NULL); return pDoc;}CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName){ CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL); return pDoc;}3.在应用程序对象的INSTANCE 函数中将原来APPWIZARD生成的CMultiDocTemplate* pDocTemplate; m_pDocTemplate = new CMultiDocTemplate( IDR_CURVETYPE, RUNTIME_CLASS(CCurveDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCurveView)); AddDocTemplate(m_pDocTemplate);改为// CMultiDocTemplate* pDocTemplate; m_pDocTemplate = new CMultiDocTemplate( IDR_CURVETYPE, RUNTIME_CLASS(CCurveDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCurveView)); AddDocTemplate(m_pDocTemplate); m_pDocTemplateModule = new CMultiDocTemplate( IDR_CURVETYPE, RUNTIME_CLASS(CModuleDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CModuleView)); AddDocTemplate(m_pDocTemplateModule);//可共享CChildFrame4.改写应用程序对象的ONFILENEW为如下:void CCurveApp::OnFileNew() { // TODO: Add your command handler code here return;}5.在菜单上添加两个菜单项,分别对应相应的文件类型,并添加消息映射,在它们的消息映射中调用相对应的OpenCurveDocumentFile或OpenModuleDocumentFile 请问下面的错误是什么意思??谢谢 如何直接读取directx捕获的一侦为bmp数据或图像的二维矩阵,直接放在内存中 线程池的问题 关于字符串数组清空的问题。请指教! new 和 delete 的问题; ===到底什么时候"->"用什么时候用"."呢! === 如何给结构体中的某个变量赋初值? unexpected end of file while looking for precompiled header directive 如何在线程中使用树控件 ?????windows2000/98的关机代码??? 采集图象存取问题 我写了一个QQ想开源但有些问题还不清楚
CMultiDocTemplate* m_pDocTemplate;
CMultiDocTemplate* m_pDocTemplateModule;
CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName)
CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName)2.在应用程序类中的INSTANCE函数中把原来的"CMultiDocTemplate* pDocTemplate;"改为如下:
m_pDocTemplate = new CMultiDocTemplate(
IDR_CURVETYPE,
RUNTIME_CLASS(CCurveDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CCurveView));
AddDocTemplate(m_pDocTemplate);
m_pDocTemplateModule = new CMultiDocTemplate(
IDR_CURVETYPE,
RUNTIME_CLASS(CModuleDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CModuleView));
AddDocTemplate(m_pDocTemplateModule);
3.重载ONFILENEW,并直接返回
4.在文件菜单上插入两个与你文件类型对应菜单,并添加消息映射在相应的消息映射中调用那两个成员函数
5.成员函数的实现如下:
CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName)
{
CDocument* pDoc = NULL;
pDoc = m_pDocTemplateModule->OpenDocumentFile(NULL);
pDoc->SetTitle("模块单元");
return pDoc;
}CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName)
{
CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL);
return pDoc;
}
CDocument* OpenCurveDocumentFile(LPCTSTR lpszFileName);
CDocument* OpenModuleDocumentFile(LPCTSTR lpszFileName);
CMultiDocTemplate* m_pDocTemplate;
CMultiDocTemplate* m_pDocTemplateModule;2.上面两个函数的实现如下:
CDocument* CCurveApp::OpenModuleDocumentFile(LPCTSTR lpszFileName)
{
CDocument* pDoc = NULL;
pDoc = m_pDocTemplateModule->OpenDocumentFile(NULL);
return pDoc;
}CDocument* CCurveApp::OpenCurveDocumentFile(LPCTSTR lpszFileName)
{
CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL);
return pDoc;
}3.在应用程序对象的INSTANCE 函数中将原来APPWIZARD生成的
CMultiDocTemplate* pDocTemplate;
m_pDocTemplate = new CMultiDocTemplate(
IDR_CURVETYPE,
RUNTIME_CLASS(CCurveDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CCurveView));
AddDocTemplate(m_pDocTemplate);
改为
// CMultiDocTemplate* pDocTemplate;
m_pDocTemplate = new CMultiDocTemplate(
IDR_CURVETYPE,
RUNTIME_CLASS(CCurveDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CCurveView));
AddDocTemplate(m_pDocTemplate);
m_pDocTemplateModule = new CMultiDocTemplate(
IDR_CURVETYPE,
RUNTIME_CLASS(CModuleDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CModuleView));
AddDocTemplate(m_pDocTemplateModule);
//可共享CChildFrame
4.改写应用程序对象的ONFILENEW为如下:
void CCurveApp::OnFileNew()
{
// TODO: Add your command handler code here
return;
}
5.在菜单上添加两个菜单项,分别对应相应的文件类型,并添加消息映射,在它们的消息映射中调用相对应的
OpenCurveDocumentFile或OpenModuleDocumentFile