【发布时间】:2013-01-03 15:45:40
【问题描述】:
简单的问题:那是什么信息?它是从哪里来的?
症状:
我在关闭时遇到 CWnd::WalkPreTranslateMessage 崩溃 我的应用程序。这是由处理的消息引起的 CWinApp::PreTranslateMessage 主框架被销毁及其C++后 对象被破坏并且在 MFC 内部处理 WM_QUIT 消息之前 - 我不调用(Afx)PostQuitMessage。
我重载了 CWinApp::PreTranslateMessage 来跟踪消息 路过。
这发生在 VS2005(32 位)和 VS2010(64 位)以及调试和发布模式下。
时间线:
- CWinThread::m_pMainWnd 为 NULL(已正确销毁)
-
CWinApp::PreTranslateMessage 被调用
它的参数MSG* message看起来像:
hwnd: NULL message: varies from 49390 to 49401 wParam: 17 lParam: looks random=> 在 CWnd::WalkPreTranslateMessage
中崩溃
在运行时,我看到带有该 ID 的消息通过 CWinApp::PreTranslateMessage。有一种消息 有趣的可能有助于确定这些消息的位置 来自:
MSG* 消息看起来像:
hwnd: NULL
message: 49390
wParam: 17
lParam: looks random at first, though ...
lParam hiword: is incremented by 1 each time the message passes through
lParam loword: is constant
这些消息似乎是 hwnd 明确为 NULL 的线程消息。 我仍然想知道它们有什么用,如何阻止它们填充消息队列 或如何处理它们以免在关闭时使应用程序崩溃。
好吧,现在我这样处理是不对的。
if (m_pMainWnd)
return CWinApp::PreTranslateMessage(pMsg);
else
return FALSE;
请帮我识别这些消息,谢谢!
【问题讨论】: