如何改变ComboBox的下拉按钮的颜色?尽量用最简单的方法。

解决方案 »

  1.   

    在消息WM_CTRLCOLOR的函数中更改,就是楼上所说的OnCtlColor中。
    可以根据控件类型返回不同的颜色刷子。
      

  2.   

    派生一个CComboBox类,添加消息映射
    ON_WM_CTLCOLOR_REFLECT
    添加函数afx_msg HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor );
    HBRUSH CMyComboBox::CtlColor(CDC* pDC, UINT nCtlColor)
    {
    nCtlColor=CTLCOLOR_LISTBOX;
    SetBkColor(RGB(0,255,0));
    HBRUSH b=CreateSolidBrush(RGB(0,255,0));
    return b;
    }
      

  3.   

    对,那个被封杀的kingcom说的对,应该不行,看错题目了,不好意思。
    估计要实现这个功能得自己在CComboBox上继承出来个类自己实现画按钮的功能了。
      

  4.   

    从CComboBox派生自己的子类,重载其DrawItem在其中更改,然后使用SubclassDlgItem就可以方便的更改现有的对象
      

  5.   

    right,还是继承以后,在新类上修改吧。
      

  6.   

    The framework calls this member function when a child control is about to be drawn. Most controls send this message to their parent (usually a dialog box) to prepare the pDC for drawing the control using the correct colors.To change the text color, call the SetTextColor member function with the desired red, green, and blue (RGB) values. To change the background color of a single-line edit control, set the brush handle in both the CTLCOLOR_EDIT and CTLCOLOR_MSGBOX message codes, and call the CDC::SetBkColor function in response to the CTLCOLOR_EDIT code.OnCtlColor will not be called for the list box of a drop-down combo box because the drop-down list box is actually a child of the combo box and not a child of the window. To change the color of the drop-down list box, create a CComboBox with an override of OnCtlColor that checks for CTLCOLOR_LISTBOX in the nCtlColor parameter. In this handler, the SetBkColor member function must be used to set the background color for the text.Note   This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function
      

  7.   

    lorryyj520(紫菜蛋汤520的方法应该行吧
      

  8.   

    可能连DrawItem都不好使...得直接在paint(or ncpain)中处理估计...
      

  9.   

    去网址
    http://www.codeproject.com/combobox/customcombo.asp自己下载吧