// TODO: Change any attributes of the DC here if (nCtlColor==CTLCOLOR_STATIC) { pDC->SetTextColor(RGB(255,255,0)); } if (nCtlColor==CTLCOLOR_DLG||nCtlColor==CTLCOLOR_STATIC) { pDC->SetBkColor(RGB(0,0,0)); HBRUSH m_Bkdlg=CreateSolidBrush(RGB(0,0,0)); return m_Bkdlg; }
if(bReleaseDC) { ReleaseDC(pDC); } // TODO: Return a different brush if the default is not desired return hbr; }
其实还是贴代码比较好,方便大家查找错误
HBRUSH CDutyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
BOOL bReleaseDC=FALSE;
if(pDC==NULL)
{
pDC=GetDC();
bReleaseDC=TRUE;
} HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(255,255,0));
}
if (nCtlColor==CTLCOLOR_DLG||nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(0,0,0));
HBRUSH m_Bkdlg=CreateSolidBrush(RGB(0,0,0));
return m_Bkdlg;
}
if(bReleaseDC)
{ ReleaseDC(pDC);
} // TODO: Return a different brush if the default is not desired
return hbr;
}