void CVcSendISDMDlg::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = (NMLVCUSTOMDRAW*)pNMHDR;
*pResult = CDRF_DODEFAULT;
if (pLVCD->nmcd.dwDrawStage == CDDS_PREPAINT)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (pLVCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM ))
{
int nItem = pLVCD->nmcd.dwItemSpec;
int nSubItem = pLVCD->iSubItem;
CRect rect;
CString str="";
str = m_listctr.GetItemText(nItem, nSubItem);
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
m_listctr.GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect);
if (m_listctr.GetItemState(nItem, LVIS_SELECTED))
DrawListItem(str, pDC, 0x00ff00, 0x0000ff , rect);
else if(0 == nItem %2)
DrawListItem(str, pDC, 0x0000ff, 0xffffee , rect);
else
DrawListItem(str, pDC, 0x00ff00, 0x00ffff , rect);
*pResult = CDRF_SKIPDEFAULT;
}
void CVcSendISDMDlg::DrawListItem(CString str, CDC *pDC, COLORREF crText, COLORREF crBkgnd, CRect &rect)
{
pDC->FillSolidRect(&rect, crBkgnd);
if (!str.IsEmpty())
{
UINT nFormat = DT_VCENTER | DT_LEFT | DT_EXPANDTABS;
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(crText);
pDC->SetBkColor(crBkgnd);
str = " " + str;
pDC->DrawText(str, &rect, nFormat);
}
}