16,472
社区成员
发帖
与我相关
我的任务
分享
if((pWnd-> GetDlgCtrlID() == IDC_EDIT1) && (nCtlColor == CTLCOLOR_EDIT)&&(m_num1=="pass"))
{
pDC-> SetTextColor(RGB(255,0,0)); //设置红色的文本
pDC-> SetBkColor(RGB(0,0,0)); //设置黑色的文本背景
pDC-> SetBkMode(OPAQUE); //设置是否为不透明
HBRUSH m_brMine = CreateSolidBrush(RGB(255,255,0)); //设置黄色的控件背景
return m_brMine; //作为约定,返回背景色对应的刷子句柄
}
HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we are trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// Are we painting the IDC_MYSTATIC control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
// Set the text color to red.
pDC->SetTextColor(RGB(255, 0, 0));
// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object.
hbr = m_brush;
}
return hbr;
}