Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list box notifications

I have dialog box with two controls: tree view and list box. I also have message handler for my dialog box.

 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;

So, I can't understand why notifications from tree box comes succesfully, but notifications from list box never comes, despite the fact that in the properties of list box' control Notify value is set TRUE. Thank you.

like image 351
Myosotis Avatar asked Mar 13 '12 06:03

Myosotis


1 Answers

Let's check the documentation.

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.

Conclusion: List boxes use WM_COMMAND to notify the parent, not WM_NOTIFY.

like image 118
Raymond Chen Avatar answered Sep 28 '22 04:09

Raymond Chen