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. Urgent: Combo Box

Urgent: Combo Box

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 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.
  • S Offline
    S Offline
    syedhassan4
    wrote on last edited by
    #1

    I have very simple problem that When I disable the ComboBox which has type "DropDown". It becomes grayed. I want it to be in White Color. I use "OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)" to change it but it dose not work properly .:confused: I wrote following code Following are Class Variables CBrush bkBrush; CBrush rBrush; BOOL CMyDialogBox::OnInitDialog() { CDialog::OnInitDialog(); . . . rBrush.CreateSolidBrush(RGB(255,255,255)); bkBrush.CreateSolidBrush(RGB(255,255,255)); . . . } HBRUSH CMyDialogBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here switch(pWnd->GetDlgCtrlID()) { case IDC_COMBO: pDC->SetBkMode(TRANSPARENT); if(GetDlgItem(IDC_COMBO) != GetFocus()) hbr = rBrush; else hbr = bkBrush; break; default: break; } // TODO: Return a different brush if the default is not desired return hbr; } Remember that ComboBox has property of Drop Down. Thanks in advance.

    P 1 Reply Last reply
    0
    • S syedhassan4

      I have very simple problem that When I disable the ComboBox which has type "DropDown". It becomes grayed. I want it to be in White Color. I use "OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)" to change it but it dose not work properly .:confused: I wrote following code Following are Class Variables CBrush bkBrush; CBrush rBrush; BOOL CMyDialogBox::OnInitDialog() { CDialog::OnInitDialog(); . . . rBrush.CreateSolidBrush(RGB(255,255,255)); bkBrush.CreateSolidBrush(RGB(255,255,255)); . . . } HBRUSH CMyDialogBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here switch(pWnd->GetDlgCtrlID()) { case IDC_COMBO: pDC->SetBkMode(TRANSPARENT); if(GetDlgItem(IDC_COMBO) != GetFocus()) hbr = rBrush; else hbr = bkBrush; break; default: break; } // TODO: Return a different brush if the default is not desired return hbr; } Remember that ComboBox has property of Drop Down. Thanks in advance.

      P Offline
      P Offline
      Prem Kumar
      wrote on last edited by
      #2

      Use the following code, if( pWnd->GetDlgCtrlID() == 1001 && pWnd->GetParent()->GetDlgCtrlID() == IDC_CMB ) return (HBRUSH)m_Brush ; Here theIDC_CMB is the id of the combo box. In general the edit box of the combo has the ID of 1001. This information is obtained by using Spy++. But i do not think it will be changed in future.

      S 1 Reply Last reply
      0
      • P Prem Kumar

        Use the following code, if( pWnd->GetDlgCtrlID() == 1001 && pWnd->GetParent()->GetDlgCtrlID() == IDC_CMB ) return (HBRUSH)m_Brush ; Here theIDC_CMB is the id of the combo box. In general the edit box of the combo has the ID of 1001. This information is obtained by using Spy++. But i do not think it will be changed in future.

        S Offline
        S Offline
        syedhassan4
        wrote on last edited by
        #3

        Sorry!!! It is Drop List.

        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