请问一个多文档的视图切换问题!在线等待!想了好久了!
我想作在多文档中对两个视图进行切换,不知道写的方法有没有错,但我是这样写的如下 我在CMainFrame中:
void CMainFrame::OnViewSwitch(int iChangeView)
{
CView* pOldView = MDIGetActive()->GetActiveView(); ;
ASSERT_VALID(pOldView);
CView* pNewView = NULL;
if(iChangeView == 1)
{
pNewView = (CView*)new CHtmView;
}
else
{
pNewView = (CView*)new CMyView;
}
ASSERT_VALID(pNewView);
CCreateContext context;
context.m_pCurrentDoc = pOldView->GetDocument();
pNewView->Create(NULL, NULL, WS_BORDER ¦WS_CHILD, CFrameWnd::rectDefault,this, iChangeView ,&context);
pNewView->OnInitialUpdate();
SetActiveView(pNewView);
pNewView->ShowWindow(SW_SHOW);
pOldView->ShowWindow(SW_HIDE);
//::SetWindowLong(pNewView->m_hWnd,GWL_ID,AFX_IDW_PANE_FIRST);
RecalcLayout();
delete pOldView;
}
可是运行到RecalcLayout()时就会在objcore.cpp中的如下方法是的CRuntimeClass* pClassThis = GetRuntimeClass();出现错误。
BOOL CObject::IsKindOf(const CRuntimeClass* pClass) const
{
ASSERT(this != NULL);
// it better be in valid memory, at least for CObject size
ASSERT(AfxIsValidAddress(this, sizeof(CObject)));
// simple SI case
CRuntimeClass* pClassThis = GetRuntimeClass();
return pClassThis->IsDerivedFrom(pClass);
}
错误提示:2.exe 中的 0x7c22700a (mfc71d.dll) 处未处理的异常: 0xC0000005: 读取位置 0xfeeefeee 时发生访问冲突 。
我一直找不到错误不知道为什么呢?