可不可以先搞一副位图涂上你要的颜色,再用CButton::SetBitmap

解决方案 »

  1.   

    OnCtlColor里这么做HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
       // Call the base class implementation first! Otherwise, it may
       // undo what we're trying to accomplish here.
       HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);   // Are we painting the IDC_MYSTATIC control? We can use
       // CWnd::GetDlgCtrlID() to perform the most efficient test.
       if (pWnd->GetDlgCtrlID() == IDB_MYBUTTON)
       {
          // Set the back color
          pDC->SetBkColor(RGB(255, 0, 0));
          hbr = m_brush;
       }   return hbr;
    }
      

  2.   

    emmai 不对。
    CButton着色很麻烦,不过我见过现成的类,可以着色。
      

  3.   

    emmai不对;
    自己生成一个CButton的子类
    并改写DrawItem()
    在DrawItem()中自己画,
    呵呵。。
      

  4.   

    emmai,不好意思,你能不能将过程详细点告诉我。拜托!!
      

  5.   

    onsky2000
    你见过类到底是什么类,详细一点,好不好。
      

  6.   

    绘制有纹理的背景的应用程序 (jiangsheng翻译)
    http://www.csdn.net/develop/read_article.asp?id=9603
      

  7.   

    to emmai(WaTaXiWaWaTaXi) :请问:
      if (pWnd->GetDlgCtrlID() == IDB_MYBUTTON)
      { ....
      }
    IDB_MYBUTTON 在哪定义的?在MSDN查不到的!请赐教!
      

  8.   

    TO :WRONGT
    IDB_MYBUTTON是自己用CBUTTON派生类CREATE时指定的,或绑定通过资源编辑器加上的按馏;
    我觉得在CBUTTON类中改写ONCTLCTRL()函数可以达到要求.
      

  9.   

    错了,EMMAIL说的在对话类中改写可能不行,应该自己派生一个BUTTON类,在该
    类里改写ONCTLCTRL()消息函数.