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. Change background color of combo box's dropdown list.

Change background color of combo box's dropdown list.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 Posts 2 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.
  • U Offline
    U Offline
    User 3831761
    wrote on last edited by
    #1

    Hello, How to change the background color of the dropdown list in combo box. I changed the back ground color of dialog box in OnCtlColor() method, this changed the color of all the items on the dialog. I could individual controls color but not able to change the dropdown list color of combo box. Below is the code snippet. if(pWnd->GetDlgCtrlID() == IDC_COMBO1) { HBRUSH g_bkcolor = CreateSolidBrush(RGB(255,255,255)); pDC->SetTextColor(RGB(0,0,0)); pDC->SetBkColor (RGB(255,255,255)); hbr = g_bkcolor; return hbr; } If someone knows how to change the color please let me know.. Thank You..

    P 1 Reply Last reply
    0
    • U User 3831761

      Hello, How to change the background color of the dropdown list in combo box. I changed the back ground color of dialog box in OnCtlColor() method, this changed the color of all the items on the dialog. I could individual controls color but not able to change the dropdown list color of combo box. Below is the code snippet. if(pWnd->GetDlgCtrlID() == IDC_COMBO1) { HBRUSH g_bkcolor = CreateSolidBrush(RGB(255,255,255)); pDC->SetTextColor(RGB(0,0,0)); pDC->SetBkColor (RGB(255,255,255)); hbr = g_bkcolor; return hbr; } If someone knows how to change the color please let me know.. Thank You..

      P Offline
      P Offline
      PrafullaShirke27
      wrote on last edited by
      #2

      1.Derive the Combo box class 2.Overide the WM_CREATE message i.e CBS_OWNERDRAWFIXED in Create function 3. Handel the DrawItem function of Combobox Here a. Fill the Item's rectabgle with the color you wanted to show as background b. Then drawtext on top of it. I think this much clue is sufficient.

      U 1 Reply Last reply
      0
      • P PrafullaShirke27

        1.Derive the Combo box class 2.Overide the WM_CREATE message i.e CBS_OWNERDRAWFIXED in Create function 3. Handel the DrawItem function of Combobox Here a. Fill the Item's rectabgle with the color you wanted to show as background b. Then drawtext on top of it. I think this much clue is sufficient.

        U Offline
        U Offline
        User 3831761
        wrote on last edited by
        #3

        Thanks for the reply. I am not that expect in MFC to get it. Could you explain it with an example? Than you once again..

        P 1 Reply Last reply
        0
        • U User 3831761

          Thanks for the reply. I am not that expect in MFC to get it. Could you explain it with an example? Than you once again..

          P Offline
          P Offline
          PrafullaShirke27
          wrote on last edited by
          #4

          Using colors in CEdit and CStatic[^] This article will help you to understand how to create the custom control according to requirement. After understanding those start working on your combo box.

          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