debug assertion failed winocc.cpp line:138 好不容易下载到一个程序,不能打开,大大们帮我一下吧!急! 190
一操作就会报错,搜了半天也不知道怎么改,麻烦各位啦,这个软件真的很重要!
138 ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlCont == NULL)
::SetDlgItemText(m_hWnd, nID, lpszString);
else
m_pCtrlCont->SetDlgItemText(nID, lpszString);
} 展开
这个应该是创建窗口代码的问题。
ASSERT是断言,是C++中用于调试的一个宏。其原理如下:检查传入参数是否为FALSE(即0),如果是则在stderr中输出错误并弹窗提示,伪代码如下:
void myassert(int canshu){
if(canshu){
return;
}
else{
//进行弹窗和输出
}
}
好的,进入正文。
其报错部位代码为ASSERT(::IsWindow(m_hWnd));
由m_hWnd可判断出此程序使用MFC编写,而IsWindow函数用于判断窗口是否有效,传进判断句柄。若窗口有效则输出TRUE,否则为FALSE。
下面是MSDN对该函数的解释:
IsWindow function (winuser.h)
10/13/2021
2 minutes to read
Is this page helpful?
C++CopyBOOL IsWindow( [in, optional] HWND hWnd );
Determines whether the specified window handle identifies an existing window.
Syntax
Parameters
[in, optional] hWnd
Type: HWND
A handle to the window to be tested.
Return value
Type: BOOL
If the window handle identifies an existing window, the return value is nonzero.
If the window handle does not identify an existing window, the return value is zero.
Remarks
A thread should not use IsWindow for a window that it did not create because the window could be destroyed after this function was called. Further, because window handles are recycled the handle could even point to a different window.
Examples
For an example, see Creating a Modeless Dialog Box.
那么,可以看出,由于某种原因,句柄或者句柄对应的窗口无效,导致IsWindow返回了FALSE,而ASSERT收到了返回值FALSE,判断该函数出错,因此报错。
总结,这应该是程序编写者的代码在创建窗口时出错,应该向程序作者反馈。