捕捉键盘后,在程序中创建一新的有模式对话框。结束后为什么出现错误?
我在主对话框中的BOOL CCPJHDlg::PreTranslateMessage(MSG* pMsg) 中加入了:
if(pMsg->message == WM_KEYDOWN) {
if(pMsg->wParam == VK_F2)
{
OnButton2();
}
....
}
void CCPJHDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CDlgCSMan dlg_csm;
int nResponse;
nResponse=dlg_csman.DoModal();
}
按F2后弹出dlg_csm对话框,再按确定,dlg_csm消失后系统就会提示出错。这是怎么回事?
错误信息内容是:
Debug Assertion Failed!
Program:.........\CPJH.exe
File:wincore.cpp
Line:875
...
调试后,Wincore.cpp的部分内容是
// check for special wnd??? values
ASSERT(HWND_TOP == NULL); // same as desktop
if (m_hWnd == HWND_BOTTOM)
ASSERT(this == &CWnd::wndBottom);
else if (m_hWnd == HWND_TOPMOST)
ASSERT(this == &CWnd::wndTopMost);
else if (m_hWnd == HWND_NOTOPMOST)
ASSERT(this == &CWnd::wndNoTopMost);
else
{
// should be a normal window
第875行:-->> ASSERT(::IsWindow(m_hWnd));
// should also be in the permanent or temporary handle map
CHandleMap* pMap = afxMapHWND();
ASSERT(pMap != NULL);
CObject* p;
ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL ||
(p = pMap->LookupTemporary(m_hWnd)) != NULL);
ASSERT((CWnd*)p == this); // must be us
哪位高手可以指点一下,谢谢!!