Click to See Complete Forum and Search --> : Custom drawn ListView- can't receive CDRF_NOTIFYITEMDRAW


lunaroverlord
January 10th, 2009, 08:09 PM
I'm custom-drawing a listview control, but while I can receive the CDDS_PREPAINT message, the CDDS_ITEMPREPAINT never comes. I've searched around and tried various things, but to no avail.

Here is the WM_NOTIFY message:

DWORD result; //global variable

...

case WM_NOTIFY:
if(((LPNMHDR)lp)->code==NM_CUSTOMDRAW && ((LPNMHDR)lp)->idFrom == 5467)
{

LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lp;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT: //this message is processed fine
result = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT: //I never receive this one
{
int iRow = lplvcd->nmcd.dwItemSpec;
if(iRow & 1)
{
lplvcd->clrTextBk = RGB(255, 34, 100);
lplvcd->clrText = RGB(255, 22, 2);
result = CDRF_NEWFONT;
}
result = CDRF_DODEFAULT;
}
break;
default:
result = CDRF_DODEFAULT;
}
return result;
}


What could be the reason for this? Thanks for any help.

carl666
January 11th, 2009, 06:07 AM
It's a Win32 FAQ (famous since 1995...)
(see news://comp.os.ms-windows.programmer.win32)

Marc G
January 11th, 2009, 06:45 AM
Did you try CDRF_NOTIFYSUBITEMDRAW?

lunaroverlord
January 11th, 2009, 02:18 PM
Thanks for the responses, but it still doesn't work.

I tried with CDRF_NOTIFYSUBITEMDRAW, nothing. The only value that ever comes to lplvcd->nmcd.dwDrawStage is 1 (CDDS_PREPAINT), checked that in debugger. Strange, is the code not correct? Why wouldn't it notify me with the CDDS_ITEMPREPAINT message when I'm returning CDRF_NOTIFYITEMDRAW?

EDIT:
Maybe the problem's somehow related to that my ListView is not in a dialog, but in the main window?
This was the original example I borrowed my code from:

if(((LPNMHDR)lParam)->code == NM_CUSTOMDRAW)
{
SetWindowLong(hWnd, DWL_MSGRESULT,
(LONG)ProcessCustomDraw(lParam));
return TRUE;
}

Here it's used in dialog, but my ListView is a child of the main window, so I'm just returning the value to WndProc. (ProcessCustomDraw is the processing code)