I need to get the column id will be drawn. This is my some of my code I try to get item id and column id to use ListView_GetItemText and set the correct color of the item to be drawn.
switch( ((LPNMLVCUSTOMDRAW)lParam)->nmcd.dwDrawStage){
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
{
LPNMLVCUSTOMDRAW customDraw = (LPNMLVCUSTOMDRAW)lParam;
int itemid = (customDraw->nmcd).dwItemSpec //this is item id
//column id is missing
return CDRF_NEWFONT;
break;
}
default: return CDRF_DODEFAULT;
}
if you include
case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
int iSubItem = ((LPNMLVCUSTOMDRAW)lParam)->iSubItem;
break;
this will get you the column. The reason why this isn't happening is you have to return the notifications you want to receive in the future through the LRESULT pointer passed in the function header, so for instance
If your function header looked like:
::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
You'd need:
*pResult |= CDRF_NOTIFYITEMDRAW;
*pResult |= CDRF_NOTIFYSUBITEMDRAW;
*pResult |= CDRF_NOTIFYPOSTPAINT;
*pResult |= CDRF_NOTIFYPOSTERASE;
At the end of your function