我有一个 MFC 应用程序,它显示一个简单的对话框,其中包含一个自定义控件和自定义创建动态控件窗口。创建自定义控件的第一个子控件后,堆栈溢出后应用程序崩溃
这是崩溃后的调用堆栈
Amn80Lib1.dll!TPXBitButton::GetThisMessageMap() Line 1627 C++
Amn80Lib1.dll!TPXBitButton::GetMessageMap() Line 1627 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2181 C++
mfc100d.dll!CWnd::ReflectChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3408 C++
> mfc100d.dll!CWnd::OnChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3387 C++
mfc100d.dll!CButton::OnChildNotify(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 91 C++
mfc100d.dll!CWnd::SendChildNotifyLastMsg(long * pResult) Line 3327 C++
mfc100d.dll!CWnd::ReflectLastMsg(HWND__ * hWndChild, long * pResult) Line 3365 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3463 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
user32.dll!75d1c4e7() Unknown
user32.dll!75d1c5e7() Unknown
user32.dll!75d1c590() Unknown
user32.dll!75d11b31() Unknown
user32.dll!75d32bee() Unknown
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
mfc100d.dll!CWnd::Default() Line 291 C++
mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 C++
Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29 C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
The maximum number of stack frames supported by Visual Studio has been exceeded.
发送的消息总是 528 这是 0x210 = WM_PARENTNOTIFY wParam = 77594625, lParam = 3409408
我不知道这是什么原因,以及如何阻止它,我搜索了孩子是否有任何人向父母发送任何消息,但没有消息,对话框未显示,但它的窗口句柄是创建并且自定义控件也有一个句柄并且它的第一个孩子有一个句柄然后我们陷入崩溃并且其他孩子没有机会被创建。我跟踪了执行情况,发现在对话框内调用自定义控件的子控件的 create 方法后发生了崩溃。自定义控件是一个数据库导航控件,包含下一个、上一个、新建、编辑以输入记录号的按钮,此自定义控件继承自 TControl,而 TControl 继承自 CWnd。它里面的按钮是从 TButton 继承的,而 TButton 是从 CButton 继承的。
更新
问题如下:
当我注册自定义控件窗口类时,我将 windowproc 设置为 MFC windowProc ,当 MFC proc 没有找到任何方法来吃消息时,它调用了窗口的默认 proc,即导致打开递归的 MFC windowPoc,我通过将窗口进程设置为默认值来解决这个问题,如下所示
WNDCLASS wndClass;
//fill the window class data
wndClass.lpfnWndProc = ::DefWindowProc;//AfxWndProc;//this fixed it
这解决了我的问题