views:

32

answers:

1

Hi!

I create a simple window with a comboboxex (with inserting few bitmaps), I need to know when user has selected an item from combo-box(I need CBEN_ENDEDIT I think). But Parent window don't get any WM_NOTIFY from that combo-box except one value. Can anyone help me with this please? Why I can't get the notifications ?

 //Window creating
        WNDCLASSEX wcx={0}; 
        wcx.cbSize         = sizeof(WNDCLASSEX);           
        wcx.lpfnWndProc    = WndProc; 
        wcx.hInstance      = hInst;   
        RegisterClassEx(&wcx)         

        HWND parent =CreateWindowEx()//-Created with some args


 //WndProc
        switch (uMsg)
        {
        case WM_CREATE:
            {
                //-Creating comboboxex
                DWORD dwStyle = CBS_DROPDOWNLIST | WS_CHILD |WS_VISIBLE;
                HWND child = CreateWindowEx(0, WC_COMBOBOXEX,0, dwStyle, x, y, w, h,  parent, IDC_CMBX, hinst, 0) 
            }
        case WM_NOTIFY :
            {
                LPNMHDR nmhdr = (LPNMHDR)lParam;
                //Here nmhdr->code value is always 4294967279 -I think it is NM_SETCURSOR ?
            }
         }

Thank you very much.

A: 

What you probably want is CBN_SELCHANGE. From MSDN:

The CBN_SELCHANGE notification message is sent when the user changes the current selection in the list box of a combo box. The user can change the selection by clicking in the list box or by using the arrow keys. The parent window of the combo box receives this notification in the form of a WM_COMMAND message with CBN_SELCHANGE in the high-order word of the wParam parameter.

So in this case you have to handle WM_COMMAND instead of WM_NOTIFY and check if the high-order word of the wParam parameter is CBN_SELCHANGE.

humbagumba
Yeah.....It is. You saved me. Thank you very much.............And, btw why there aren't any WM_NOTIFY getting into the window from the combo-box child ?
Morpheus
Some controls use WM_NOTIFY and some use WM_COMMAND. The advantage of WM_NOTIFY is that it allows to pass more information in the form of a NMHDR structure but not all controls need/use this. Here's an interesting article: http://blogs.msdn.com/b/oldnewthing/archive/2006/03/02/542115.aspx
humbagumba