WTL拆分器示例中的调试断言

时间:2017-02-06 13:58:12

标签: c++ wtl

从使用vs2013编译的WTL sample中的主机菜单中单击读取或清除剪贴板

CHAIN_COMMANDS_MEMBER(m_wndFormatList)将来自大型机的消息发送到成员列表控件但消息为空?

堆栈跟踪:

WTLClipSpy.exe!ATL::CWindowImplRoot<WTL::CListViewCtrlT<ATL::CWindow> ::SetMsgHandled(int bHandled) Line 3213   C++
WTLClipSpy.exe!CClipSpyListCtrl::ProcessWindowMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, long & lResult, unsigned long dwMsgMapID) Line 30 C++
WTLClipSpy.exe!CMainFrame::ProcessWindowMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, long & lResult, unsigned long dwMsgMapID) Line 41   C++

调试输出:

Debug Assertion失败!

程序:... nloads \ source \ WTL4MFC7_demo \ WTLClipSpy。\ Debug \ WTLClipSpy.exe 文件:c:\ program files(x86)\ microsoft visual studio 12.0 \ vc \ atlmfc \ include \ atlwin.h 行:3213

表达式:pMsg!= 0

1 个答案:

答案 0 :(得分:1)

很可能是一个不太流行的CHAIN_COMMANDS_MEMBER宏的回归问题。

解决方法可能如下所示:

    //CHAIN_COMMANDS_MEMBER(m_wndFormatList)
    if(uMsg == WM_COMMAND)
    {
        lResult = m_wndFormatList.SendMessage(uMsg, wParam, lParam);
        if(lResult == 0)
            return TRUE;
    }

或者,如果您希望绕过SendMessage API(有意义),那么您需要在链式控件中处理m_pCurrentMsg初始化。一个更好但更长的修复。