自己建立一个对话框类CimportFileDlg,在importFileDlg.h文件中加入CView *m_pView;
然后在importFiledlg.cpp中加入#include "TestDoc.h"和#include "TestView.h"两个头文件,
然后在TestView.h文件中又#include "TestDoc.h",响应
void CImportFileDlg::OnOK()
{
CTestView *pView = (CTestView *)m_pView;
CTestDoc *pDoc = (CTestDoc *)pView->GetDocument(); CDialog::OnOK();
}断点调试,当执行到CTestDoc *pDoc = (CTestDoc *)pView->GetDocument();时出错:
Unhandled exception in Test.exe:0xc00000005 Access Violation
然后跳转到
CTestDoc* CTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)));
return (CTestDoc*)m_pDocument;
}
晕,真不知道为何会这样!
然后在importFiledlg.cpp中加入#include "TestDoc.h"和#include "TestView.h"两个头文件,
然后在TestView.h文件中又#include "TestDoc.h",响应
void CImportFileDlg::OnOK()
{
CTestView *pView = (CTestView *)m_pView;
CTestDoc *pDoc = (CTestDoc *)pView->GetDocument(); CDialog::OnOK();
}断点调试,当执行到CTestDoc *pDoc = (CTestDoc *)pView->GetDocument();时出错:
Unhandled exception in Test.exe:0xc00000005 Access Violation
然后跳转到
CTestDoc* CTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)));
return (CTestDoc*)m_pDocument;
}
晕,真不知道为何会这样!
导致这句:CTestView *pView = (CTestView *)m_pView; 这里得到的pView失败.
从而这句:CTestDoc *pDoc = (CTestDoc *)pView->GetDocument();
出现未处理异常.
dlg.m_pView = GetActiveView();dlg.DoModal();