CDC*   pDC   =  GetDlgItem(IDC_TEXT)->GetDC();
  pDC->SetTextColor(RGB(255,0,0));//字体颜色
  pDC->SetBkColor(RGB(0,255,0));//设置背景颜色没反映

解决方案 »

  1.   

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

    // TODO: Change any attributes of the DC here
    if(pWnd->GetDlgCtrlID() == IDC_EDIT1)
    {
    pDC->SetTextColor(RGB(255,0,0));
    }

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }
      

  2.   

    还是不行
    HBRUSH CMy0815Dlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here
    if(pWnd->GetDlgCtrlID() == IDC_TEXT)
    {
    pDC->SetTextColor(RGB(255,0,0));
    }

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }OnCtlColor(pDC,GetDlgItem(IDC_TEXT),0);
      

  3.   

    去看看我的博客吧
    http://blog.csdn.net/xianglitian/archive/2007/08/07/1728920.aspx
    希望对你有帮助
      

  4.   

    HBRUSH CMy0815Dlg::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_TEXT)
    {
    pDC->SetTextColor(RGB(255,0,0));//字体颜色
                      pDC->SetBkColor(RGB(0,255,0));//设置背景颜色
                      HBRUSH brush = CreateSolidBrush(RGB(0,233,220));
    return brush; }

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }
      

  5.   

    怎么调用
    void CMy0815Dlg::OnButton2() 
    {
    //OnCtlColor(GetDlgItem(IDC_TEXT)->GetDC(),this,RGB(255,0,0));
    OnCtlColor(GetDlgItem(IDC_TEXT)->GetDC(),GetDlgItem(IDC_TEXT),RGB(255,0,0));
    Invalidate();
    }
      

  6.   

    button 对
    WM_CTLCOLOR
    没用
    -------
    对button
    你baidu下
    有点繁杂!
      

  7.   

    不难你看 看就会了--
    shou xia