添加对话框的WM_CTLCOLOR消息响应函数OnCtlColorHBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );nCtlColor 就是标准控件的类型:
CTLCOLOR_BTN   Button control
CTLCOLOR_DLG   Dialog box
CTLCOLOR_EDIT   Edit control
CTLCOLOR_LISTBOX   List-box control
CTLCOLOR_MSGBOX   Message box
CTLCOLOR_SCROLLBAR   Scroll-bar control
CTLCOLOR_STATIC   Static control 看看MSDN,有例子

解决方案 »

  1.   

    自绘:
    把//DEL全部去掉就可以了
    //DEL  void CSmsDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
    //DEL  {
    //DEL  
    //DEL   // 更改界面字体颜色
    //DEL   // TODO: Add your message handler code here and/or call default
    //DEL   UINT uStyle = DFCS_BUTTONPUSH;
    //DEL  
    //DEL      // This code only works with buttons.
    //DEL      ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
    //DEL   // If drawing selected, add the pushed style to DrawFrameControl.
    //DEL   if (lpDrawItemStruct->itemState & ODS_SELECTED)
    //DEL   uStyle |= DFCS_PUSHED;
    //DEL   // Draw the button frame.
    //DEL   ::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, DFC_BUTTON, uStyle);
    //DEL  
    //DEL   // Get the button's text.
    //DEL   CString strText;
    //DEL   COLORREF crOldColor;
    //DEL   switch(nIDCtl)
    //DEL   {
    //DEL  /*
    //DEL   case IDC_SENDMSG:
    //DEL   {
    //DEL   m_nSendMsg.GetWindowText(strText);
    //DEL   // Draw the button text using the text color
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_REINPUT:
    //DEL   {
    //DEL   m_nReinput.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_HISTORY:
    //DEL   {
    //DEL   m_nHistory.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_UPGRADE:
    //DEL   {
    //DEL   m_nUpgrade.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_TIMING:
    //DEL   {
    //DEL   m_nTiming.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_QUEUE:
    //DEL   {
    //DEL   m_nQueue.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_TELEPHONEBOOK:
    //DEL   {
    //DEL   m_nTeleBook.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_CLOSE:
    //DEL   {
    //DEL   m_close.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_ABOUT:
    //DEL   {
    //DEL   m_nAbout.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,0,125));
    //DEL   break;
    //DEL   }*/
    //DEL   case IDC_LANGUAGE:
    //DEL   {
    //DEL   m_btnLanguage.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(125,0,0));
    //DEL   break;
    //DEL   }
    //DEL   case IDC_BROADCAST:
    //DEL   {
    //DEL   m_btnBroadcast.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(125,0,0));
    //DEL   break;
    //DEL   }
    //DEL  /*
    //DEL   case IDC_CHOICE:
    //DEL   {
    //DEL   m_nChoice.GetWindowText(strText);
    //DEL   crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,0,125));
    //DEL   break;
    //DEL   }*/
    //DEL   default:
    //DEL   break;
    //DEL   }
    //DEL   // Draw the button text using the text color
    //DEL   //COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(0,125,0));
    //DEL  
    //DEL   ::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
    //DEL   ::SetTextColor(lpDrawItemStruct->hDC, crOldColor);
    //DEL  
    //DEL  // CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
    //DEL  }
      

  2.   

    re Anco(DNET
    好象没有起作用,OnDrawItem()会自动执行吧?