我有两个控件的对话框: TreeView 和列表框。 我的对话框也有消息处理程序。
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case IDC_LIST1: //we NEVER comes here
if(((LPNMHDR)lParam)->code == NM_CLICK)
{
//do some work;
return (INT_PTR)TRUE;
}
break;
case IDC_TREE1:
if(((LPNMHDR)lParam)->code == NM_DBLCLK)
{
//do some work;
return (INT_PTR)TRUE;
}
break;
}
}
break;
所以,我不明白为什么来自树框的通知成功到达,但是来自列表框的通知永远不会到达,尽管在列表框控件的属性中设置了 Notify 值 <强>正确强>。 谢谢你。
最佳答案
让我们检查文档。
LBS_NOTIFY
Causes the list box to send a notification code to the parent window whenever the user clicks a list box item (LBN_SELCHANGE), double-clicks an item (LBN_DBLCLK), or cancels the selection (LBN_SELCANCEL).
Notifies the application that the selection in a list box has changed as a result of user input. The parent window of the list box receives this notification code through the WM_COMMAND message.
Notifies the application that the user has double-clicked an item in a list box. The parent window of the list box receives this notification code through the WM_COMMAND message.
Notifies the application that the user has canceled the selection in a list box. The parent window of the list box receives this notification code through the WM_COMMAND message.
结论:列表框使用WM_COMMAND
通知父级,而不是WM_NOTIFY
。
关于c++ - 列表框通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9679531/