开发者

why parent window don't get notifications from child combobox?

开发者 https://www.devze.com 2023-01-02 22:04 出处:网络
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_

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消