Hi all,

The listctrl i use now fills the subitem of an item in the listctrl with a color. This means the complete rectangle of the field is filled with that color. I think it looks better when it is slightly smaller, but i do not know if this is possible. Does somebody has a clue?
This is what i use now:
Code:
void CMyDlg::OnCustomDrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
	*pResult = 0;

	LPNMLVCUSTOMDRAW  lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
	
	// Retrieve row
	int row = lplvcd->nmcd.dwItemSpec;

	// Check if row is between valid boundaries
	if(row < 0 || row > m_lst.GetItemCount() - 1)
	{
		if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
		{
			*pResult = CDRF_NOTIFYSUBITEMDRAW;
		}
		else
		{
			*pResult = CDRF_DODEFAULT;
		}
		return;
	}

	// Retrieve item data, which contains ID, color
	CItemData* pData = (CItemData*)m_lst.GetItemData(row);
	
	switch(lplvcd->nmcd.dwDrawStage)
	{
		case CDDS_PREPAINT :
		{
			*pResult = CDRF_NOTIFYITEMDRAW;
			return;
		}

	    // Modify item text and or background
		case CDDS_ITEMPREPAINT:
		{
			// Set color of text
			lplvcd->clrText = RGB(0,0,0);
			
			// If you want the sub items the same as the item,
			// set *pResult to CDRF_NEWFONT
			*pResult = CDRF_NOTIFYSUBITEMDRAW;
			return;
		}

		// Modify sub item text and/or background
		case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM:
		{
			// Check if item to be drawn is the color column 
			if(lplvcd->iSubItem == 1)
			{
				// Retrieve color from itemdata
				if(pData)
					lplvcd->clrTextBk = pData->m_cItemColor;
			}
			*pResult = CDRF_NEWFONT;
			return;
		}
		default:// it wasn't a notification that was interesting to us.
			*pResult = CDRF_DODEFAULT;

	}
}

BOOL CMyDlg::OnEraseBkgnd(CDC* pDC) 
{
	CRect rect;
	GetClientRect(rect);

	CBrush brush0(RGB(247, 247, 247));
	CBrush brush1(RGB(255, 255, 255));

	SCROLLINFO si;
	ZeroMemory(&si, sizeof(SCROLLINFO));
    si.cbSize = sizeof(SCROLLINFO);
    si.fMask = SIF_POS;
	GetScrollInfo(SB_HORZ, &si);
	rect.left -= si.nPos;

	for(int i = 0; i <= m_lst.GetItemCount(); i++)
	{
		rect.right = rect.left + m_lst.GetColumnWidth(i);
		pDC->FillRect(&rect,i%2 ? &brush1 : &brush0);
		rect.left += m_lst.GetColumnWidth(i);
	}

	brush0.DeleteObject();
	brush1.DeleteObject();

	return FALSE;
	//return CDialog::OnEraseBkgnd(pDC);
}