http://zhidao.baidu.com/link?url=BKp05mfOdKbEBh21svQelpVhYjzDkIpYUZay8_3ZLSndTQn5kK0eTwQG8jBvYnwh8USFHoMPmozWw5odO2LN__
void CSendCommandDlg::OnNMCustomdrawList2(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVCUSTOMDRAW* lplvcd = (NMLVCUSTOMDRAW*)(pNMHDR);
int nRow = (int)lplvcd->nmcd.dwItemSpec;
switch (lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult |= CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:// 单行与双行的颜色
{
if (nRow &1)//// 单行
{
lplvcd->clrTextBk = RGB(0xFF,0xFF,0xFF);
lplvcd->clrText = RGB(0x00,0x00,0x00);
*pResult = CDRF_NEWFONT;
}else // 双行
{
lplvcd->clrTextBk = RGB(0xBB,0xCC,0xFF);
lplvcd->clrText = RGB(0x44,0x33,0x00);
*pResult = CDRF_NEWFONT;
}
if (m_List.GetCheck(nRow) && (m_List.GetExtendedStyle()& LVS_EX_CHECKBOXES))
{
lplvcd->clrTextBk = RGB(0x00,0x00,0x80);
lplvcd->clrText = RGB(0xFF,0xFF,0x00);
HFONT hFont = (HFONT)this->SendMessage(WM_GETFONT);
LOGFONT lf;
GetObject(hFont,sizeof(lf),&lf);
lf.lfStrikeOut = TRUE;// // 删除线
//lf.lfItalic = TRUE;//斜体
hFont = CreateFontIndirect(&lf);
SelectObject(lplvcd->nmcd.hdc,hFont);
DeleteObject(hFont);
*pResult = CDRF_NEWFONT;
}
if (m_List.GetItemState(nRow,CDIS_SELECTED))//选中行颜色
{
lplvcd->nmcd.uItemState &= ~CDIS_SELECTED;
lplvcd->clrTextBk = RGB(255,0,0);
lplvcd->clrText = RGB(0,0,255);
*pResult = CDRF_NEWFONT;
}
}
break;
default:
*pResult = CDRF_DODEFAULT;
break;
}
}