Hi all,

After being a silent observer for a while I've decided to ask for your help. It seems to me like I've search all the forums in the world for answers and couldn't find...

I consider myself a newbie in win32, so the fact I couldn't find the answer doesn't say anything about the problem being complex .

My task is pretty simple - I'm writing a dll to be used with nsis (Nullsoft Scriptable Install System). I want to change the color of specific subitems in a listview.

I suspect that I'm not getting notifications for the items at all, but only for the titles: let's say I have 4 colums and 10 rows (that is 10 items with 4 subitems each). In the handler I get CDDS_PREPAINT and return CDRF_NOTIFYITEMDRAW then I get 4 CDDS_ITEMPREPAINTs and for each one of them I return CDRF_NOTIFYSUBITEMDRAW, and that's it.

I also noticed that if instead of returning CDRF_NOTIFYSUBITEMDRAW I change the font and return CDRF_NEWFONT, also nothing is happening (and according to MSDN this should affect all subitems of the item).

here is the code: http://www.mediafire.com/?pd6tf3p1r269d84
it's a pack that contains also an nsis file that uses the dll, you need nsis compiler to use it. It also contains an example2.exe which is compiled with a dll in debug mode, so you can attach to it and see the notifications, and hopefully see where is the bug in my code.

lines 279-344 of URLCtrl:

LRESULT ProcessCustomDraw (LPARAM lParam)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;

switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT : //Before the paint cycle begins
//request notifications for individual listview items
return CDRF_NOTIFYITEMDRAW;
break;

case CDDS_ITEMPREPAINT: //Before an item is drawn
return CDRF_NOTIFYSUBITEMDRAW;
break;

//Before a subitem is drawn
case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
lplvcd->clrText = RGB(255,0,0);
lplvcd->clrTextBk = RGB(255,255,255);
return CDRF_NEWFONT;
break;
}
return CDRF_DODEFAULT;
}

LRESULT CALLBACK urlctrl_lv_proc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{ URLCTRLS *urls=(URLCTRLS*)GetWindowLong(hwnd,GWL_USERDATA);
WNDPROC oldproc=urls->oldproc;
LRESULT myResult = CDRF_DODEFAULT;
switch(uMsg)
{ case WM_NOTIFY:
{ switch (((LPNMHDR)lParam)->code)
{ case NM_CUSTOMDRAW:
{ myResult = ProcessCustomDraw(lParam);
return myResult;
break;
}
}
break;
}

....
....

}
return CallWindowProc(oldproc,hwnd,uMsg,wParam,lParam);
}


Thanks!

J