一个MDI程序
包含一个文档类CMyProj1Doc
和两个视图类 CMyProj1View 以及自己加的 CInputView(继承自CFormView)
在MDIChildWnd中用SplitterWnd切分窗口
问题是:
在CMyProj1View的OnDraw函数内:
CMyProj1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
没有任何问题
而在CInputView内:
CMyProj1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
编译报错error C2440: “初始化”: 无法从“CDocument *”转换为“CMyProj1Doc *”
是什么原因?将两个类对比了一下 发现区别在于一个GetDocument()函数
CMyProj1View中有一个AppWizard自动生成的函数:
CMyProj1Doc* CMyProj1View::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyProj1Doc)));
return (CMyProj1Doc*)m_pDocument;
}
而CInputView却没有
是否重写CInputView中的GetDocument()就能解决问题? 为什么?
包含一个文档类CMyProj1Doc
和两个视图类 CMyProj1View 以及自己加的 CInputView(继承自CFormView)
在MDIChildWnd中用SplitterWnd切分窗口
问题是:
在CMyProj1View的OnDraw函数内:
CMyProj1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
没有任何问题
而在CInputView内:
CMyProj1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
编译报错error C2440: “初始化”: 无法从“CDocument *”转换为“CMyProj1Doc *”
是什么原因?将两个类对比了一下 发现区别在于一个GetDocument()函数
CMyProj1View中有一个AppWizard自动生成的函数:
CMyProj1Doc* CMyProj1View::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyProj1Doc)));
return (CMyProj1Doc*)m_pDocument;
}
而CInputView却没有
是否重写CInputView中的GetDocument()就能解决问题? 为什么?
解决方案 »
- vc picture conteol jpg显示问题 [救急...]
- 这几个类都帮我们做了什么
- 关于界面问题的提问
- MFC做的对话框模式的ActiveX在IE里面调用,怎么才能作成非模态的
- 显示器数量分辨率问题
- 关于Platform SDK的使用问题
- ~~百分相送~~如何获得一个路径下的文件名和文件名的字符串
- to: DeadWolf(死狼) 做好了就来领分 我的Email: [email protected] (关于g.721压缩)
- 拜托各位,函数返回值是数组问题,如何使用!!!!!!!!!!
- 请问如何把JPG格式的扫描文档转换成WORD文档
- 如何把WINMM.LIB文件 添加到工程中去
- 链接时出现的问题
2\加上文档模板. pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME1,
RUNTIME_CLASS(CShowDEMDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CShowDEMView));
AddDocTemplate(pDocTemplate);