c++ - WinAPI : Add style to combo box

标签 c++ windows winapi

我正在尝试将 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/

相关文章:

c++ - 生成一副纸牌

c++ - 如何在一组迭代器上调用 `find`,通过迭代器指向的内容进行查找?

c# - 在 Windows Phone 8.1 上播放 GIF

c# - 如何让本地组中的所有用户(性能良好)

c++ - 较小的管道如何加速数据流?

c - Win32 滚动条 : When drag horizontal scroll bar to right most position, nPos 的值没有达到 nMaxPos

c++ - 如何命名同时充当其他集合容器的 B+Tree 键/值映射集合

c++ - Visual Studio 2012 C++ 如何在 NMake 项目中添加编译器选项

c - 获取当前用户的最后一次登录

windows - 删除指向文件的链接而不清除只读位