动态生成的CFrameWnd销毁出错。

WestDawn 2007-10-22 02:51:27
代码如下:
CTestFrame *pFrame = ( CTestFrame * )CTestFrame::CreateObject();//CTestFrame从CFrameWnd派生

CCreateContext contextT;
contextT.m_pLastView = NULL;
contextT.m_pCurrentFrame = NULL;
contextT.m_pNewDocTemplate = NULL;
contextT.m_pCurrentDoc = NULL;
contextT.m_pNewViewClass = RUNTIME_CLASS( CTestView );


DWORD dwStyle = WS_CHILD|WS_OVERLAPPEDWINDOW|MFS_SYNCACTIVE;

if ( !((CFrameWnd *)pFrame)->Create( NULL, NULL, dwStyle, CRect(0, 0, 0, 0),
pTabCtrl, 0, 0L, &contextT ) )
{
return -1;
}
pFrame->InitialUpdateFrame(NULL, FALSE);
pFrame->ShowWindow(SW_SHOW);
//在pTabCtrl中生成框架
在pTabCtrl销毁的时候销毁框架时候出错 。
错误提示:
test.exe 中的 0x7c22700a (mfc71d.dll) 处未处理的异常: 0xC0000005: 读取位置 0xfeeefeee 时发生访问冲突 。

中断指向文件objcore.cpp中如下行

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);
}

如果contextT.m_pNewViewClass = RUNTIME_CLASS( CTestView );
改成contextT.m_pNewViewClass = NULL;则不会出错。
谢谢。


...全文
122 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧