CWnd::OnCtlColorHBRUSH 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; }详细请查msdn
{
// 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;
}详细请查msdn