Hi!
I need to perform custom drawing of the items according to this rules:
1. Each first column of each item must perform owner drawing, e.g. use FillRect(), Rectangle() e.t.c.
2. Each second column of each item must perform default windows drawing.
3. And each third column of each item must perform custom drawing and fill its cell rectangle to desired color.
I found this example at msdn:
LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
switch (pnm->hdr.code){
...
case NM_CUSTOMDRAW:
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
switch(lplvcd->nmcd.dwDrawStage) {
case CDDS_PREPAINT :
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam) );
lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
...
return CDRF_NEWFONT;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrText = GetColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrTextBk = GetBkColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
...
return CDRF_NEWFONT;
}
...
}
And there are my questions:
1. Where I need to do owner drawing of first column? Here:
case CDDS_ITEMPREPAINT:
{
return CDRF_NOTIFYSUBITEMDRAW;
}
and which result I need to return in this case: CDRF_NOTIFYSUBITEMDRAW or CDRF_NOTIFYSUBITEMDRAW | CDRF_SKIPDEFAULT?
or here:
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
{
if(lplvcd->iSubItem == 0)
{
return CDRF_SKIPDEFAULT;
}
return CDRF_DODEFAULT;
}
2. What happens if here
case CDDS_ITEMPREPAINT:
I return the CDRF_NOTIFYSUBITEMDRAW? Does it mean that now I need to do drawing of
all columns (including first column) of the item in
case CDDS_SUBITEM | CDDS_ITEMPREPAINT handler?
Or I should draw first column in one case and subitems in another case? I do not understand.
Please explain me! Thanks!