CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Location
    Sweden
    Posts
    4

    Changing background color of CComboBoxEx

    ..having a bit of a problem with this one..

    -I've overridden the OnCtlColor method of CComboBoxEx, and changed the color of the background:

    ...
    COLORREF ActiveBkColor =(COLORREF)0xdae4e9;
    static CBrush ActiveBrush(ActiveBkColor);
    HBRUSH Brush;
    Brush = ActiveBrush;
    pDC->SetBkColor(ActiveBkColor);
    return Brush;

    -Looks totally OK as long as I don't look at the popped-up list, where the background of the text (only) is still white!
    -Where there is no TEXT, the background color is ok..

    Does anybody have an idea as to what I can do?

    Regards
    /Torbjörn Josefsson


  2. #2
    Guest

    Re: Changing background color of CComboBoxEx

    From MSDN documentation on CWnd::OnCtlColor:

    OnCtlColor will not be called for the list box of a drop-down combo box because the drop-down list box is actually a child of the combo box and not a child of the window. To change the color of the drop-down list box, create a CComboBox with an override of OnCtlColor that checks for CTLCOLOR_LISTBOX in the nCtlColor parameter. In this handler, the SetBkColor member function must be used to set the background color for the text.




  3. #3
    Join Date
    May 2002
    Posts
    4
    It does not work for me. Does anybody have a solution?

  4. #4
    Join Date
    Dec 1999
    Location
    Trinidad & Tobago
    Posts
    25
    Just before you set your Color in OnCtlColor, place the line:
    pDC->SetBkMode(TRANSPARENT)

    Hope this helps

    Owen

  5. #5
    Join Date
    Sep 2004
    Posts
    1

    Re: Changing background color of CComboBoxEx

    Hi,

    would u be so kind and post your complete entry in the OnCtlColor?
    I´ve the same problem and wonder how it works.

    THX!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured