CDC* pDC = GetDlgItem(IDC_TEXT)->GetDC();
pDC->SetTextColor(RGB(255,0,0));//字体颜色
pDC->SetBkColor(RGB(0,255,0));//设置背景颜色没反映
pDC->SetTextColor(RGB(255,0,0));//字体颜色
pDC->SetBkColor(RGB(0,255,0));//设置背景颜色没反映
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID() == IDC_EDIT1)
{
pDC->SetTextColor(RGB(255,0,0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
HBRUSH CMy0815Dlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID() == IDC_TEXT)
{
pDC->SetTextColor(RGB(255,0,0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}OnCtlColor(pDC,GetDlgItem(IDC_TEXT),0);
http://blog.csdn.net/xianglitian/archive/2007/08/07/1728920.aspx
希望对你有帮助
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if( nCtlColor == IDC_TEXT)
{
pDC->SetTextColor(RGB(255,0,0));//字体颜色
pDC->SetBkColor(RGB(0,255,0));//设置背景颜色
HBRUSH brush = CreateSolidBrush(RGB(0,233,220));
return brush; }
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CMy0815Dlg::OnButton2()
{
//OnCtlColor(GetDlgItem(IDC_TEXT)->GetDC(),this,RGB(255,0,0));
OnCtlColor(GetDlgItem(IDC_TEXT)->GetDC(),GetDlgItem(IDC_TEXT),RGB(255,0,0));
Invalidate();
}
WM_CTLCOLOR
没用
-------
对button
你baidu下
有点繁杂!
shou xia