在子类化 CButton 时,我希望每次按下按钮时按钮的颜色都会增加。但是以下对背景颜色没有任何作用。但是,文本显示“c”以递增。谢谢
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
CButton::OnLButtonDown(nFlags, point);
static int c;
CString s;
s.Format("left: %d", c*50);
this->SetWindowText(s);
////// Neither of the following change the background color
//CPaintDC dc(this);
//dc.SetBkColor(0x0 + c*50);
CDC *dc= GetDC();
dc->SetBkColor(0x0 + c*50);
c++;
}