我想让一个编辑框的颜色和对话框的颜色融为一体于是我做了以下工作:
HBRUSH CFirstTestView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
GetDlgItem(IDC_EDIT1)->GetDC()->SetBkMode(TRANSPARENT);
GetDlgItem(IDC_EDIT1)->GetDC()->SetBkColor(GetSysColor(COLOR_WINDOW));
hbr=(HBRUSH)(COLOR_WINDOW);
// TODO: Return a different brush if the default is not desired
return hbr;
}
但是编辑框依旧“发白”,请赐教!
HBRUSH CFirstTestView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
GetDlgItem(IDC_EDIT1)->GetDC()->SetBkMode(TRANSPARENT);
GetDlgItem(IDC_EDIT1)->GetDC()->SetBkColor(GetSysColor(COLOR_WINDOW));
hbr=(HBRUSH)(COLOR_WINDOW);
// TODO: Return a different brush if the default is not desired
return hbr;
}
但是编辑框依旧“发白”,请赐教!
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor== CTLCOLOR_DLG)hbr=CreateSolidBrush(RGB(255,0,0));
return hbr;
}
对话框的背景是COLOR_BTNFACE
这个是在系统中改的,要想只改程序中的,那就要重载一个 CEdit 了