Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Changing colours of a combo box (reposted)

Changing colours of a combo box (reposted)

Scheduled Pinned Locked Moved C / C++ / MFC
workspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alton Williams
    wrote on last edited by
    #1

    Hi, I've subclassed CComboBox. I've setup the background and text colours called Invalidate(). Which works perfectly well with the edit box. It's when I dropdown it's crashing the app. I want to able to change the colour of the listbox part as well. Here's the code snippet: BEGIN_MESSAGE_MAP(CComboEx, CComboBox) //{{AFX_MSG_MAP(CComboEx) ON_WM_CTLCOLOR_REFLECT() ON_WM_CTLCOLOR() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CComboEx message handlers HBRUSH CComboEx::CtlColor(CDC* pDC, UINT nCtlColor) { // TODO: Change any attributes of the DC here /* // TODO: Return a non-NULL brush if the parent's handler should not be called if(nCtlColor = CTLCOLOR_LISTBOX) { return OnCtlColor(pDC,this,nCtlColor); } */ pDC->SetTextColor(m_Text); pDC->SetBkColor(m_Background); pDC->SetBkMode(TRANSPARENT); m_brush.DeleteObject(); m_brush.CreateSolidBrush(m_Background); return m_brush; } HBRUSH CComboEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); return hbr; } Thanks in advance, Alton

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups