1. 手动添加NM_CUSTOMDRAW
2.处理函数:
NMLVCUSTOMDRAW* pNMCD = (NMLVCUSTOMDRAW*)(pNMHDR);
if (CDDS_PREPAINT == pNMCD->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (CDDS_ITEMPREPAINT == pNMCD->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pNMCD->nmcd.dwDrawStage)
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>(pNMCD->nmcd.dwItemSpec);
if (nItem % 2)
{
clrNewTextColor = RGB(0 , 0 , 0);
clrNewBkColor = RGB(204 , 255 , 255);
}
else
{
clrNewTextColor = RGB( 0, 0, 0);
clrNewBkColor = RGB(255 , 255 ,255);
}
pNMCD->clrText = clrNewTextColor;
pNMCD->clrTextBk = clrNewBkColor;
*pResult = CDRF_DODEFAULT;
}