本帖最后由 VisualEleven 于 2012-08-27 07:50:07 编辑

解决方案 »

  1.   

    改变Button的颜色必须要自绘,重写CButton类,添加处理虚函数DrawItem,MSDN上有例子代码。// NOTE: CMyButton is a class derived from CButton. The CMyButton
    // object was created as follows:
    //
    // CMyButton myButton;
    // myButton.Create(_T("My button"), 
    //      WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, 
    //      CRect(10,10,100,30), pParentWnd, 1);
    //// This example implements the DrawItem method for a CButton-derived 
    // class that draws the button's text using the color red.
    void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
    {
       UINT uStyle = DFCS_BUTTONPUSH;   // This code only works with buttons.
       ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);   // If drawing selected, add the pushed style to DrawFrameControl.
       if (lpDrawItemStruct->itemState & ODS_SELECTED)
          uStyle |= DFCS_PUSHED;   // Draw the button frame.
       ::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, 
          DFC_BUTTON, uStyle);   // Get the button's text.
       CString strText;
       GetWindowText(strText);   // Draw the button text using the text color red.
       COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(255,0,0));
       ::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), 
          &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
       ::SetTextColor(lpDrawItemStruct->hDC, crOldColor);
    }注意看看前面的注释
      

  2.   

    点击OK和Cancel键就改变一个全局BOOL变量的值
    在WM_CTLCOLORBTN消息处理中去绘制其背景和颜色
      

  3.   

    在网上搜索一个CColorButton 之类的类,就可以了

    http://www.codeguru.com/
    http://www.codeproject.com/
    上很多实现好的子类
    在CSDN的下载频道,也有不少资源
    个性的界面资源,靠积累...
      

  4.   

    动态加载CBitmapButton的四副状态图
    http://www.vckbase.com/index.php/cv/640