15,980
社区成员
发帖
与我相关
我的任务
分享
case 1001:
{
pDC-> SetTextColor(RGB(0,0,0));
pDC-> SetBkMode(TRANSPARENT);
HBRUSH b=CreateSolidBrush(red);
return b;
}
case 1000:
{
pDC-> SetTextColor(RGB(0,0,0));
pDC-> SetBkMode(TRANSPARENT);
HBRUSH b=CreateSolidBrush(yellow);
return b;
}
#define WRITE_BRUSH RGB(255,255,255)
#define YELLOW_BRUSH RGB(255,255,0)
#define ORANGE_BRUSH RGB(247,148,29)
#define RED_BRUSH RGB(255,0,0)
HBRUSH m_bBrush[4]; //成员变量
// 对话框的构造函数中初始化
m_bBrush[0] = CreateSolidBrush(WRITE_BRUSH);
m_bBrush[1] = CreateSolidBrush(YELLOW_BRUSH);
m_bBrush[2] = CreateSolidBrush(ORANGE_BRUSH);
m_bBrush[3] = CreateSolidBrush(RED_BRUSH);
// WM_CTLCOLOR消息响应函数
HBRUSH CXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(pWnd->GetDlgCtrlID())
{
case IDC_EDIT1:
pDC->SetTextColor(WHITE_BRUSH);
pDC->SetBkMode(TRANSPARENT);
return m_bBrush[3];
case IDC_EDIT2:
pDC->SetTextColor(YELLOW_BRUSH);
pDC->SetBkMode(TRANSPARENT);
return m_bBrush[2];
case IDC_EDIT3:
pDC->SetTextColor(ORANGE_BRUSH);
pDC->SetBkMode(TRANSPARENT);
return m_bBrush[1];
case IDC_EDIT4:
pDC->SetTextColor(RED_BRUSH);
pDC->SetBkMode(TRANSPARENT);
return m_bBrush[0];
default:
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}