展开全部
重载对话框的WM_CTLCOLOR对应的虚函数
下面的代码是一个个更改
如果你想把同类的控件改变颜色
可以用
if(nCtlColor==CTLCOLOR_STATIC)
HBRUSH CSetPaintPenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
if (pWnd==this)
{
return m_bkBrush;
}
if (pWnd->GetDlgCtrlID()==IDC_REMARK)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,0,0));
CFont *pOldFont=pDC->SelectObject(&m_font);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC1==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC2==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC3==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO1)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO2)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO3)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
return hbr;
}
下面的代码是一个个更改
如果你想把同类的控件改变颜色
可以用
if(nCtlColor==CTLCOLOR_STATIC)
HBRUSH CSetPaintPenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
if (pWnd==this)
{
return m_bkBrush;
}
if (pWnd->GetDlgCtrlID()==IDC_REMARK)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,0,0));
CFont *pOldFont=pDC->SelectObject(&m_font);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC1==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC2==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (IDC_STATIC3==pWnd->GetDlgCtrlID())
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO1)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO2)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
if (pWnd->GetDlgCtrlID()==IDC_RADIO3)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
return hbr;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询