I am using CComboBox in my project. I want to change the color of the border combo box on focus
Asked
Active
Viewed 973 times
0
-
For background color, I can advise you to see documentation about `OnCtlColor` – sergiol Dec 28 '16 at 12:43
-
@sergiol I have checked it is not working – Anoop Kumar Dec 29 '16 at 05:03
-
Show your code, what you have trying. – Tom Tom Dec 29 '16 at 06:00
-
Use Spy++ to check what messages are passing. – sergiol Dec 29 '16 at 14:02
1 Answers
0
Finally 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