【问题标题】:MFC CWinApp::PreTranslateMessage: Identify message (ID: 49390) which causes crash while closingMFC CWinApp::PreTranslateMessage:识别消息(ID:49390),导致关闭时崩溃
【发布时间】:2013-01-03 15:45:40
【问题描述】:

简单的问题:那是什么信息?它是从哪里来的?

症状:

我在关闭时遇到 CWnd::WalkPreTranslateMessage 崩溃 我的应用程序。这是由处理的消息引起的 CWinApp::PreTranslateMessage 主框架被销毁及其C++后 对象被破坏并且在 MFC 内部处理 WM_QUIT 消息之前 - 我不调用(Afx)PostQuitMessage

我重载了 CWinApp::PreTranslateMessage 来跟踪消息 路过。

这发生在 VS2005(32 位)和 VS2010(64 位)以及调试和发布模式下。

时间线:

  1. CWinThread::m_pMainWnd 为 NULL(已正确销毁)
  2. 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;

请帮我识别这些消息,谢谢!

【问题讨论】:

    标签: mfc crash message


    【解决方案1】:

    RegisterWindowMessage 返回该范围内的消息(高于 0xC000 的任何消息)。我怀疑你做错了什么,因为这种事情不应该发生——而且在正确编写的 MFC 应用程序中也不应该发生。

    【讨论】:

    • 谢谢!我会看看那个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-09
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    相关资源
    最近更新 更多