更改CComboBox的边框颜色以显示错误和警告(Change border color of CComboBox to show error and warning)

编程入门 行业动态 更新时间:2024-10-27 09:48:34
更改CComboBox的边框颜色以显示错误和警告(Change border color of CComboBox to show error and warning)

我在我的项目中使用CComboBox。 我想在焦点上更改边框组合框的颜色

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

最满意答案

在此处输入图像描述 最后它完成了,它有一个非常简单的解决方案。 我刚刚覆盖了控件的onpaint方法。

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; }

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; }

更多推荐

CComboBox,color,change,电脑培训,计算机培训,IT培训"/> <meta name="descri

本文发布于:2023-07-26 19:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边框   颜色   错误   Change   CComboBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!