awg
June 3rd, 1999, 11:44 PM
I use the following handler to change the text color and text backgroung of subitems in a ListView.
void CTestView::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
switch(pCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
{
switch (pCD->iSubItem)
{
case 3:
pCD->clrText = IsSubItemNegative() ? RGB(160,0,0) : RGB(0,0,0);
// If this subitem is negative value text should be red
// on all other cases text color is black
break;
default:
pCD->clrText = RGB(0,0,0);
break;
}
// row background is different on odd and even items
pCD->clrTextBk = (pCD->nmcd.dwItemSpec % 2 > 0) ? RGB(200,240,240): RGB(255,255,255);
*pResult = CDRF_NEWFONT;
}
break;
}
}
The problem I can't find a solution is that everything is changed and displayed OK but when an item is selected the above handler does not work.
What am I missing? Is there a different handling for the selected items? What differentiates a selected item from a normal in stage drawing and appearance?
void CTestView::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
switch(pCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
{
switch (pCD->iSubItem)
{
case 3:
pCD->clrText = IsSubItemNegative() ? RGB(160,0,0) : RGB(0,0,0);
// If this subitem is negative value text should be red
// on all other cases text color is black
break;
default:
pCD->clrText = RGB(0,0,0);
break;
}
// row background is different on odd and even items
pCD->clrTextBk = (pCD->nmcd.dwItemSpec % 2 > 0) ? RGB(200,240,240): RGB(255,255,255);
*pResult = CDRF_NEWFONT;
}
break;
}
}
The problem I can't find a solution is that everything is changed and displayed OK but when an item is selected the above handler does not work.
What am I missing? Is there a different handling for the selected items? What differentiates a selected item from a normal in stage drawing and appearance?