HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here
//这段没起作用啊?
         if(nCtlColor == IDC_OPEN)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
return mybrush;
}
         //这段没起作用啊?
// TODO: Return a different brush if the default is not desired
//return hbr;
return mybrush;
}对话框背景倒是变了。

解决方案 »

  1.   


    if(nCtlColor == IDC_OPEN)> if (nCtlColor == CTLCOLOR_STATIC)   // Static control For other control ,refers to MSDN
      

  2.   

    对静态控件起作用了,可是对按钮没用,是这样写的
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here
    if(nCtlColor == CTLCOLOR_STATIC)
    {
    pDC->SetTextColor(RGB(255,0,0));
    pDC->SetBkMode(TRANSPARENT);
    return mybrush;
    }
    if(nCtlColor == CTLCOLOR_BTN)
    {
    pDC->SetTextColor(RGB(255,0,0));
    pDC->SetBkMode(TRANSPARENT);
    return mybrush;
    }