CCombobox下拉背景颜色 [英] CCombobox dropdown background color

查看:607
本文介绍了CCombobox下拉背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在向ccombobox加载字符串,我也想更改它的下拉背景颜色。



dc-> FillSolidRect(&rc,CustomColor);



我已将此代码添加到重写OnDrawItem方法



它使用自定义颜色填充整个下拉菜单,但之前添加到组合框的文本将不会显示。



如何使文本可见填充组合框背景颜色

Hi,

I am loading strings to ccombobox and i also want to change the dropdown background color of it.

dc->FillSolidRect(&rc, CustomColor);

I have added this code to overriding OnDrawItem method

It fills entire drop down with the custom color but the text previously added to combobox will not be shown.

How to make text visible after filling the combobox background color

推荐答案

而不是覆盖OnDrawItem,你需要覆盖OnCtlColor,如下所示:



Instead of overriding OnDrawItem you need to override OnCtlColor like this:

HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    if (nCtlColor == CTLCOLOR_LISTBOX)
        pDC->SetBkColor(RGB(255, 0, 0));

    return CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
}


这篇关于CCombobox下拉背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆