HBRUSH CPenWidthsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we're 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_EDIT)
{
// 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
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hbr;
}
本文介绍了一个C++应用程序中如何通过重写OnCtlColor函数来改变IDC_EDIT控件的颜色属性,包括文本颜色、背景模式及背景刷对象的设置。

1469

被折叠的 条评论
为什么被折叠?



