这样的错误谁遇到过,如何解决?

smallfool 2002-03-06 01:54:49
wincore.cpp 行 957诊断错误.

BOOL CWnd::DestroyWindow()
{
if (m_hWnd == NULL)
return FALSE;


CHandleMap* pMap = afxMapHWND();
ASSERT(pMap != NULL);
//错误出现在这里,好象是个窗口映射诊断错误,
据我所知,MFC给每一个CWnd 窗口建立了一个内在的句柄映射以更好地管理这些窗口
,当这个窗口删除的时候,该窗口所对的句柄映射也应该及时删除并调整该内部影射表,不知道为什么我总是会出现这个错误.谁能解释一下?

CWnd* pWnd = (CWnd*)pMap->LookupPermanent(m_hWnd);
#ifdef _DEBUG
HWND hWndOrig = m_hWnd;
#endif

#ifdef _AFX_NO_OCC_SUPPORT
BOOL bResult = ::DestroyWindow(m_hWnd);
#else //_AFX_NO_OCC_SUPPORT
BOOL bResult;
if (m_pCtrlSite == NULL)
bResult = ::DestroyWindow(m_hWnd);
else
bResult = m_pCtrlSite->DestroyControl();
#endif //_AFX_NO_OCC_SUPPORT

// Note that 'this' may have been deleted at this point,
// (but only if pWnd != NULL)
if (pWnd != NULL)
{
// Should have been detached by OnNcDestroy
#ifdef _DEBUG
ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
#endif
}
else
{
#ifdef _DEBUG
ASSERT(m_hWnd == hWndOrig);
#endif
// Detach after DestroyWindow called just in case
Detach();
}
return bResult;
}
...全文
56 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
smallfool 2002-03-18
  • 打赏
  • 举报
回复
这其实是由于程序自身不稳定而导致中途终止而引起的,当然,如果对于多线程程序来说,更容易出现这样的问题.所以还是有几个哥们能得到分的.
WingfireWu 2002-03-06
  • 打赏
  • 举报
回复
多线程中传CWnd*参数是不安全的,因为afxMapHWND()取当前线程的窗口Map, 应该传HWND
WingfireWu 2002-03-06
  • 打赏
  • 举报
回复
你是不是在线程中Destroy其它线程创建的窗口?

1,650

社区成员

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

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