// 实现
protected:
CBrush m_Brush;
BOOL CtestDlg::OnInitDialog()
{
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP2);
m_Brush.CreatePatternBrush(&bm);
}
消息:ON_WM_CTLCOLOR()
HBRUSH CtestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd == this)
{
return m_Brush;
}
if (nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_BTN)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(
GetSysColor(COLOR_WINDOWTEXT));
return (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
}
/*
switch (pWnd->GetDlgCtrlID())
{
case IDXX1:
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
break;
case IDXX2:
pDC->SetTextColor(RGB(XXX,XXX,XXX));
pDC->SetBkMode(TRANSPARENT);
break;
}
*/
return hbr;
}