0

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

Anoop Kumar
  • 137
  • 10

1 Answers1

0

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;
}
Anoop Kumar
  • 137
  • 10
  • This doesn't look right. Painting should always use a `CPaintDC`. Besides that, it is completely unclear, what `m_Parent` is, or its `combobox` member for that matter. This answer is not generally useful, sorry. – IInspectable Dec 31 '16 at 19:54
  • CComboboxown is my class where m_parent is the member variable of CComboCntl class. – Anoop Kumar Jan 02 '17 at 06:25