gpt4 book ai didi

c++ - WinAPI : Add style to combo box

转载 作者:可可西里 更新时间:2023-11-01 11:28:20 29 4
gpt4 key购买 nike

我正在尝试将 CBS_OWNERDRAWFIXED 样式添加到现有的组合框,我的代码不起作用,我也不知道为什么。我怀疑可能是表达 oldStyle | addedStyle 无效,但我不明白为什么。

    HWND hwnd = CreateWindow(
L"ComboBox",
L"",
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST ,
200,
200,
200,
200,
parentHandle,
(HMENU)1,
GetModuleHandle(NULL),
NULL);

auto comboBoxStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
comboBoxStyle = comboBoxStyle | CBS_OWNERDRAWFIXED;
SetWindowLongPtr(hwnd, GWL_STYLE, comboBoxStyle);

输出只是常规的组合框,没有任何变化。

最佳答案

此特定样式只能在创建时指定。 documentation当它说:

CBS_OWNERDRAWFIXED

Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are all the same height. The owner window receives a WM_MEASUREITEM message when the combo box is created and a WM_DRAWITEM message when a visual aspect of the combo box has changed.

关于c++ - WinAPI : Add style to combo box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28095356/

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