// TODO: Change any attributes of the DC here //change the color of dialog if(nCtlColor==CTLCOLOR_DLG) { pDC->SetBkColor(RGB(100,150,200)); return m_hDlgFace; } //change the color of static if(nCtlColor==CTLCOLOR_STATIC) { pDC->SetBkColor(RGB(100,150,200)); pDC->SetTextColor(RGB(0,0,255)); return m_hDlgFace; }
// TODO: Change any attributes of the DC here //change the color of dialog if(nCtlColor==CTLCOLOR_DLG) { pDC->SetBkColor(RGB(100,150,200)); return m_hDlgFace; } //change the color of static if(nCtlColor==CTLCOLOR_STATIC) { pDC->SetBkColor(RGB(100,150,200)); pDC->SetTextColor(RGB(0,0,255)); return m_hDlgFace; } //EDIT控件只能用这种方法,我也不知道为什么 if(pWnd->GetDlgCtrlID()==IDC_EDIT1) { pDC->SetBkColor(RGB(100,180,200)); return m_hPage2Face; }
SetTextColor()
对话框的背景颜色是可以用WM_PAINT消息的,
HBRUSH h;
h=CreateSolidBrush(...);
CRect rc;
::GetClientRect(...);
pDC->FillRect(...);
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here //change the color of dialog
if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetBkColor(RGB(100,150,200));
return m_hDlgFace;
} //change the color of static
if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(100,150,200));
pDC->SetTextColor(RGB(0,0,255));
return m_hDlgFace;
}
return hbr;
}
{
CDialog::OnInitDialog();
... ...
m_hDlgFace=CreateSolidBrush(RGB(100,150,200));
m_hPage2Face=CreateSolidBrush(RGB(100,180,200));
... ...
return TRUE;
}HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here //change the color of dialog
if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetBkColor(RGB(100,150,200));
return m_hDlgFace;
} //change the color of static
if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(100,150,200));
pDC->SetTextColor(RGB(0,0,255));
return m_hDlgFace;
} //EDIT控件只能用这种方法,我也不知道为什么
if(pWnd->GetDlgCtrlID()==IDC_EDIT1)
{
pDC->SetBkColor(RGB(100,180,200));
return m_hPage2Face;
}
return hbr;
}至于Default Button 的背景颜色是无法改的,除非你改掉BTN_FACE的值
这样的话你的Windows中所有的Default Button的背景颜色都会改变,
我唯一能想出的办法是用Owner Draw 的Button,自己画一个,要什么颜色
都行。
http://www.codeguru.com/buttonctrl/color_button.shtml
里有一个color button的例子,你自己看看吧。