c++ - 列表框通知

标签 c++ visual-studio-2010 winapi

我有两个控件的对话框: 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 值 <强>正确。 谢谢你。

最佳答案

让我们检查文档。

List Box Styles :

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).

LBN_SELCHANGE :

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.

LBN_DBLCLK :

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.

LBN_SELCANCEL :

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/

相关文章:

c# - 您如何处理从编写托管代码到非托管代码的过程?

c++ - 我在使用 std::stack 从递归函数中检索值时遇到问题

c# - 为什么我的 Windows 窗体应用程序在不同计算机之间改变大小?

visual-studio-2010 - 未使用该用户名登录时,如何使用 Windows 身份验证连接到 SQL Server?

c++ - 在 C++ 上获取帐户区分名称 AD

c++ - 在 Visual Studio 2017 上使用 VC++ 2015 工具链时缺少 ATL header

c++ - 如何使用 nlohmann json 在 C++ 中将相同的关键 json 数据合并为一个

visual-studio-2010 - 无法使用 devenv 编译 vdproj - 'targeting ' x6 4' is not compatible with the project' s 目标平台 'x86' '

c++ - Win32 Windows 线程安全吗?

c++ - 动态加载窗口图标