我想改变按钮的颜色!不知道如何做?请大侠帮忙!

解决方案 »

  1.   

    可以在按钮上边放图片。或者设置按钮的Owner Draw属性。
    然后:void COwnerDrawDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
    {
    char btnText[16];
        HBRUSH          hBrush ;
    GetDlgItemText(lpDrawItemStruct->CtlID,btnText,16);
    hBrush=CreateSolidBrush(RGB(213,192,228));
    hBrush=(HBRUSH) SelectObject (lpDrawItemStruct->hDC,hBrush);
    SetBkColor(lpDrawItemStruct->hDC,RGB(213,192,228));
    SetTextColor(lpDrawItemStruct->hDC,RGB(0,0,255));
    Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom); DrawText(lpDrawItemStruct->hDC,btnText,-1,&lpDrawItemStruct->rcItem,
    DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    DeleteObject(SelectObject(lpDrawItemStruct->hDC,hBrush));
    if (lpDrawItemStruct->itemState & ODS_SELECTED)
    InvertRect (lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem);
    }
      

  2.   

    唯一的办法,从CButton派生一个,自己画.
      

  3.   

    方法有两种:
    1:自己画
    2:处理WM_CTLCOLOR