Urgent: Combo Box
-
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.
-
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.
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.
-
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.
Sorry!!! It is Drop List.