按照网上搜到的方法:新建一个从CButton派生的类,重写DrawItem ,这些工作都在代码里面完成了,网上推荐的方法太复杂,我只是想简单的改变一下背景及文本颜色,该怎么做?void CBtn::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
}
{
// TODO: Add your code to draw the specified item
}
{
// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
pDC->SetBkMode(TRANSPARENT); // 改背景
pDC->FillSolidRect(lpDIS->rcItem, RGB(255, 0, 0)); // 颜色自己定,这里是红色 // 改文字
pDC->DrawText(_T("button text"), lpDIS->rcItem, DT_CENTER); // 改变背景
}