请问哪们高手能帮我改一下CListCtrl控件的背影颜色,谢谢!

解决方案 »

  1.   

    CListCtrl::SetBkColor
    BOOL SetBkColor( COLORREF cr );Return ValueNonzero if successful; otherwise zero.ParameterscrBackground color to set, or the CLR_NONE value for no background color. List view controls with background colors redraw themselves significantly faster than those without background colors. For information, seeCOLORREF in the Platform SDK.ResSets the background color of the list view control.Example// The pointer to my list view control.
    extern CListCtrl* pmyListCtrl;// Use the 3D button face color for the background.
    COLORREF crBkColor = ::GetSysColor(COLOR_3DFACE);
    pmyListCtrl->SetBkColor(crBkColor);
    ASSERT(pmyListCtrl->GetBkColor() == crBkColor);CListCtrl Overview |  Class Members |  Hierarchy ChartSee Also   CListCtrl::GetBkColor
      

  2.   

    做一个它的派生类
    COLORREF m_clrBack;
    CBrush brush;在构造函数中
    m_clrBack=RGB(255,0,0);
    brush.createsolidbrush(m_clrBack);处理WM_CTLCOLOR消息
    pDC->setbkcolor(m_clrBack);
    return (HBRUSH)brush.getsafehandle();
      

  3.   

    响应WM_CTLCOLOR消息,返回一个HBRUSH.
    OnCtlColorHBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
       // Call the base class implementation first! Otherwise, it may
       // undo what we're 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;
    }