微调按钮控件(CSpinButtonCtrl)有上下两个调节数值的箭头按钮,怎样改变它们的颜色?

解决方案 »

  1.   

    这个估计和CButton一样,要自绘吧
      

  2.   

    Button的作法是重载DrawItem:
    virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
    可是微调按钮控件(CSpinButtonCtrl)的DrawItem断点时根本进步去,
      

  3.   

    //CColorSpin.h
    class CColorSpin: public CSpinButtonCtrl
    {
    public:
    virtual void PreSubclassWindow();
    virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
    protected:
    //{{AFX_MSG(CColorSpin)
    afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
    // CColorSpin.cpp
    BEGIN_MESSAGE_MAP(CColorSpin, CSpinButtonCtrl)
    //{{AFX_MSG_MAP(CColorSpin)
    ON_WM_DRAWITEM()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/*virtual*/void CColorSpin::PreSubclassWindow() 
    {
    // Make the control owner-drawn
    ModifyStyle (BS_TYPEMASK, BS_OWNERDRAW, SWP_FRAMECHANGED);
    CSpinButtonCtrl::PreSubclassWindow();
    }/*virtual*/void CColorSpin::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) 
    { //断点时进步去!
    CDC* pDC = CDC::FromHandle (lpDrawItemStruct->hDC);
    ASSERT (pDC != NULL);
    }void CColorSpin::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
    {//断点时也进步去!
    CSpinButtonCtrl::OnDrawItem(nIDCtl, lpDrawItemStruct);
    CDC* pDC = CDC::FromHandle (lpDrawItemStruct->hDC);
    ASSERT (pDC != NULL);
    }OnDrawItem怎么也进不去呢?奇怪,
      

  4.   

    微调按钮不支持 ownerdraw,所以不会响应OnDrawItem
      

  5.   

    看看这个吧 http://www.codeproject.com/KB/miscctrl/lbspin.aspx
      

  6.   

    自定义SpinButtonCtrl类,继承CSpinButtonCtrl
    处理WM_CTLCOLOR消息函数,改变控件颜色.
      

  7.   

    结论就是在OnPaint里重绘~谢谢大家!
    ---------------------------------
    问题贴的分数有点少,只能象征下了!