visual-c++mfcactivexcontrolsccombobox

Change border color of CComboBox to show error and warning


I am using CComboBox in my project. I want to change the color of the border combo box on focus


Solution

  • enter image description hereFinally it is done and it has a very easy solution. I just overridden the onpaint method of the control.

    void CComboBoxOwn::OnPaint()
    {
    CDC *dc = m_Parent->combobox->GetDC();
    CRect rc; 
    m_Parent->combobox->GetClientRect(rc);
    HBRUSH hBrush = CreateSolidBrush(COLORREF(RGB(255, 0, 0)));
    FrameRect(dc->m_hDC, rc, hBrush);
    DeleteObject(hBrush);
    ReleaseDC(dc);
    
    return;
    }