WinApi:向组合框添加样式

WinApi : Add style to combo box

我正在尝试向现有的组合框添加 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.