changing the color of my controls to white using OnCtlColor
-
I want my dialog backgroung color to be grey thus i'm using OnCtlColor event but the problem is that the controls like combo box or edit control are also geting colored with grey. Please tell me how can i change the color of my controls to white???? i used the below code where CBrush m_Brush; HBRUSH CCTLColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); pDC->SetBkColor(RGB(210,209,213)); //if(pWnd->GetDlgCtrlID() == IDC_COMBO1) //{ pDC->SetBkColor(RGB(0,0,0)); //} //if(pWnd->GetDlgCtrlID() == IDC_EDIT1) //{ pDC->SetBkColor(RGB(0,0,0)); //} return m_Brush; } BOOL CCTLColorDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_Brush.CreateSolidBrush(RGB(210,209,213)); return TRUE; // return TRUE unless you set the focus to a control }
-
I want my dialog backgroung color to be grey thus i'm using OnCtlColor event but the problem is that the controls like combo box or edit control are also geting colored with grey. Please tell me how can i change the color of my controls to white???? i used the below code where CBrush m_Brush; HBRUSH CCTLColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); pDC->SetBkColor(RGB(210,209,213)); //if(pWnd->GetDlgCtrlID() == IDC_COMBO1) //{ pDC->SetBkColor(RGB(0,0,0)); //} //if(pWnd->GetDlgCtrlID() == IDC_EDIT1) //{ pDC->SetBkColor(RGB(0,0,0)); //} return m_Brush; } BOOL CCTLColorDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_Brush.CreateSolidBrush(RGB(210,209,213)); return TRUE; // return TRUE unless you set the focus to a control }
If you check out the documentation[^], you learn that the
nCtlColor
parameter tells you what is asking for the color, so you can filter out the queries.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <