(ATL) ComboBox Problem mit Vertical Scroll



  • Hallo,

    ich habe ein ATL basiertes ComboBox Control erstellt, stoße allerdings auf ein Problem. Und zwar wird, wenn sehr viele Items in der ComboBox über ::AddItem(BSTR Item, LONG Index) eingefügt werden, die vertikale Scrollbar nicht angezeigt.

    Der Constructor des Controls sieht (gekürzt) so aus:
    CXComboBox::CXComboBox() : m_cwComboBox(_T("COMBOBOX"), this, 0), m_hbrBackground(NULL), m_hbrWindow(NULL)
    {
    m_nComboStyle = csDropDownCombo; // 0 - Dropdown Combo
    }

    m_cwComboBox ist ein CContainedWindow

    Ich instanziiere das Control über CreateControlWindow()
    HWND CXComboBox::CreateControlWindow(HWND hWndParent, RECT& rcPos)
    {
    HRESULT hr = S_OK;

    DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CBS_DISABLENOSCROLL;

    // Apply combo style
    if (m_nComboStyle == csDropDownCombo)
    dwStyle |= CBS_DROPDOWN;
    else if (m_nComboStyle == csSimpleCombo)
    dwStyle |= CBS_SIMPLE;
    else
    dwStyle |= CBS_DROPDOWNLIST;

    // Apply sorted mode
    if (m_vbSorted == VARIANT_TRUE)
    dwStyle |= CBS_SORT;

    // Apply appearance
    if (m_nAppearance == appFlat)
    dwStyle |= BS_FLAT;

    m_hWnd = m_cwComboBox.Create(hWndParent, rcPos, _T(""), dwStyle);

    if (m_hWnd)
    {
    m_rcClientPos = rcPos;

    SetAmbientFont();

    BOOL bUserMode;
    hr = GetAmbientUserMode(bUserMode);
    if (SUCCEEDED(hr) && bUserMode)
    {
    ::EnableWindow(m_hWnd, m_vbEnabled == VARIANT_TRUE ? TRUE : FALSE);

    put_Enabled(m_vbEnabled);
    put_Visible(m_vbVisible);
    }

    UINT uFlags = SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE;

    CRect rc;
    ::GetWindowRect(m_hWnd, &rc);

    m_OrigHeight = rc.Height();

    ::SetWindowPos(m_hWnd, NULL, 0, 0, rc.Width(), m_OrigHeight + m_lDroppedHeight, uFlags);
    }

    return m_hWnd;
    }

    Fällt euch da irgendetwas Seltsames auf, dass dieses Problem erklären könnte

    Ich verwende VC++ 6.0 und ATL 3

    Viele Grüße


Anmelden zum Antworten