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。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步