• CListBox没产生LBN_SELCHANGE消息


    WTL中,定义CListBox的消息接收。 

    COMMAND_HANDLER_EX(IDB_HOME_DICT_KEY_LIST,LBN_SELCHANGE, OnListItemchanged)

    死活都没有触发到 LBN_SELCHANGE 的消息。

    开始以为是消息订阅的问题。

    后来用接收所有消息的宏 

    用COMMAND_ID_HANDLER_EX(IDB_HOME_DICT_KEY_LIST, OnListItemMsg) 

    发现只看到有得到焦点和失去焦点的消息产生。

    后查MSDN。

    This notification message is not sent if the LB_SETCURSEL message changes the selection.

    This notification message applies only to a list box that has the LBS_NOTIFY style.

    For a multiple-selection list box, the LBN_SELCHANGE notification is sent whenever the user presses an arrow key, even if the selection does not change.  

    原来需要设置style为 

    LBS_NOTIFY

    后来修改为: 

    m_pKeyList = new CListBox;

    m_pKeyList->Create(m_dlg->GetViewHWND(),
    NULL,
    NULL,
    WS_VISIBLE | WS_CHILDWINDOW |  LBS_NOTIFY ,
    0,IDB_HOME_DICT_KEY_LIST);

     终于能收到 

    LBN_SELCHANGE。

  • 相关阅读:
    LeetCode485 最大连续1的个数
    LeetCode167 两数之和 II
    js浮点数类型
    js整数类型
    js布尔类型
    js重复赋值 js数据交换 js调式方法
    JavaScript变量
    数据类型分类
    重复赋值 数据交换 查看程序执行结果
    JS注释 JS变量
  • 原文地址:https://www.cnblogs.com/wantfly/p/CListBox.html
Copyright © 2020-2023  润新知