// TODO: Change any attributes of the DC here switch (pWnd->GetDlgCtrlID()) { case IDXX1: pDC->SetTextColor(RGB(XXX,XXX,XXX)); pDC->SetBkMode(TRANSPARENT); break; case IDXX2: pDC->SetTextColor(RGB(XXX,XXX,XXX)); pDC->SetBkMode(TRANSPARENT); break; ...
}
// TODO: Return a different brush if the default is not desired return hbr; }
彩色按钮
选中Owner draw运行程序按扭不见了,不知道怎么会事。
既然OnCtlColor的参数nCtlColor有选项CTLCOLOR_BTN,为什么不能象改变static一样改变呢??
HBRUSH CyouDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_BUTTON1)
{
hbr = m_brush;
} return hbr;
}再试试!!!
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch (pWnd->GetDlgCtrlID())
{
case IDXX1:
pDC->SetTextColor(RGB(XXX,XXX,XXX));
pDC->SetBkMode(TRANSPARENT);
break;
case IDXX2:
pDC->SetTextColor(RGB(XXX,XXX,XXX));
pDC->SetBkMode(TRANSPARENT);
break;
...
}
// TODO: Return a different brush if the default is not desired
return hbr;
}