sorry,是DrawItem,
注意重载完要改一下形式virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );

解决方案 »

  1.   

    Create()是指定:LVS_SHOWSELALWAYS style
      

  2.   

    ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)void CListCtrlEx::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
    {
      NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
      switch (pCD->nmcd.dwDrawStage)
      {
         case  CDDS_PREPAINT:
             *pResult = CDRF_NOTIFYITEMDRAW;
             break;
         case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
             *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
             break;
         case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
             {
                 CDC* pDC = CDC::FromHandle(pCD->nmcd.hdc);
                 .....
                 .....
                 break;
              }
         default:
               if (!(pCD->nmcd.uItemState & CDIS_FOCUS))
                    *pResult = CDRF_DODEFAULT;
               else
                    *pResult = CDRF_NOTIFYSUBITEMDRAW;
               break;
           }
    }
      

  3.   

    BEGIN_MESSAGE_MAP(CCheckNetWorkDlg, CDialog)
    //{{AFX_MSG_MAP(CCheckNetWorkDlg)
    .....
    //}}AFX_MSG_MAP
    .....
    ON_NOTIFY(NM_CUSTOMDRAW, IDC_REPORT, OnCustomdrawList)  //定义消息
    END_MESSAGE_MAP()void CCheckNetWorkDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
    {
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );    // Take the default processing unless we set this to something else below.
        *pResult = 0;    // First thing - check the draw stage. If it's the control's prepaint
        // stage, then tell Windows we want messages for every item.
        if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
            {
            *pResult = CDRF_NOTIFYITEMDRAW;
            }
        else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
            {
            // This is the prepaint stage for an item. Here's where we set the
            // item's text color. Our return value will tell Windows to draw the
            // item itself, but it will use the new color we set here.
            // We'll cycle the colors through red, green, and light blue.
            COLORREF crText;
    // crText = RGB(0,0,0);
            if (m_bHost[pLVCD->nmcd.dwItemSpec])   //指定要改变颜色的Item
                crText = RGB(255,255,255);
    else
    crText = RGB(255,0,0);        // Store the color back in the NMLVCUSTOMDRAW struct.
    //        pLVCD->clrText = crText;
    pLVCD->clrTextBk=crText;        // Tell Windows to paint the control itself.
            *pResult = CDRF_DODEFAULT;
            }
    }