多文档界面中自己另外定义了一个视图类CControlView和一个文档类CCONTROLDoc,请问视图类CControlView如何调用文档类CCONTROLDoc的序列化函数?
我在应用程序类CPKASApp的InitInstance()函数中定义了一个文档模板指针,说明如下:pDocControlTemplate = new CMultiDocTemplate(
IDR_CONTROLTYPE,
RUNTIME_CLASS(CCONTROLDoc),
RUNTIME_CLASS(CCONTROLChildFrame), // custom MDI child frame
RUNTIME_CLASS(CControlView));
AddDocTemplate(pDocControlTemplate); 我给CControlView定义了一个GetDocument函数如下:
CCONTROLDoc* CControlView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCONTROLDoc)));
return (CCONTROLDoc*)m_pDocument;
}然后给"打开控制文件"子菜单定义了一给函数如下:void CControlView::OnFileOpen2()
{
CCONTROLDoc *pDoc=GetDocument();
pDoc->Serialize(CArchive &ar);
}调试时老出现如下错误:
error C2065: 'ar' : undeclared identifier
error C2275: 'CArchive' : illegal use of this type as an expression
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(1752) : see declaration of 'CArchive'急盼指教!!!
我在应用程序类CPKASApp的InitInstance()函数中定义了一个文档模板指针,说明如下:pDocControlTemplate = new CMultiDocTemplate(
IDR_CONTROLTYPE,
RUNTIME_CLASS(CCONTROLDoc),
RUNTIME_CLASS(CCONTROLChildFrame), // custom MDI child frame
RUNTIME_CLASS(CControlView));
AddDocTemplate(pDocControlTemplate); 我给CControlView定义了一个GetDocument函数如下:
CCONTROLDoc* CControlView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCONTROLDoc)));
return (CCONTROLDoc*)m_pDocument;
}然后给"打开控制文件"子菜单定义了一给函数如下:void CControlView::OnFileOpen2()
{
CCONTROLDoc *pDoc=GetDocument();
pDoc->Serialize(CArchive &ar);
}调试时老出现如下错误:
error C2065: 'ar' : undeclared identifier
error C2275: 'CArchive' : illegal use of this type as an expression
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(1752) : see declaration of 'CArchive'急盼指教!!!
解决方案 »
- 帮忙写个高效的字符串分隔函数
- new 在通讯程序中失败
- 相对路径问题 高手请帮忙
- 如何根据执行程序弹出的异常框,定位到对应的代码错误
- 请各位高手帮忙。。在线等。在线给分。如何在另一个类中调用一个类的变量。
- 用RegCreateKey函数,为什么创建注册表五个主键下的子键不可以,而其它的子键又可以?
- 单文档缩放VIEW问题,急!!!!!!!
- friend test operator+(test& i, test& j)的问题
- 愚人求教(MFC ODBC)
- 用ado打开有密码的access2000数据库出错,help!
- 关于聊天程序服务器端接受代码的问题(急!)
- 请各位大哥给小弟解答(有关制作帮助系统的问题)
函数调用错误,,,参数不用指定类型,,另外,,要将CArchive对象与文件关联起来,才能进行文件的输入输出
有一个简单的方法,不要在CControlView中拦截菜单消息,在CMyApp中拦截,,
即:
void CMyApp::OnFileOpen2()
{
CDocument::OnFileOpen();
}
void CMyApp::OnFileOpen2()
{
CWinApp::OnFileOpen();
}