gpt4 book ai didi

c++ - 为什么父窗口没有收到来自子组合框的通知?

转载 作者:行者123 更新时间:2023-11-28 08:28:58 25 4
gpt4 key购买 nike

我创建了一个带有组合框的简单窗口(插入了一些位图),我需要知道用户何时从组合框中选择了一个项目(我认为我需要 CBEN_ENDEDIT)。但是除了一个值之外,父窗口不会从该组合框中获得任何 WM_NOTIFY。有人可以帮我吗?为什么我收不到通知?

 //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 ?
}
}

非常感谢。

最佳答案

您可能需要的是 CBN_SELCHANGE。来自 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.

因此在这种情况下,您必须处理 WM_COMMAND 而不是 WM_NOTIFY,并检查 wParam 参数的高位字是否为 CBN_SELCHANGE。

关于c++ - 为什么父窗口没有收到来自子组合框的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3020763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com