I'm trying to subclass NM_CUSTOMDRAW to handle CDDS_ITEMPREPAINT messages in WndProc(not in a dialogbox) and it keeps crashing.

Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
...
 case WM_NOTIFY:
        switch(LOWORD(wParam))
        {
        case ID_LISTVIEW:
            LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
            if(pnm->hdr.code == NM_CUSTOMDRAW)
            {
               OldList = (WNDPROC) SetWindowLong(hWin_1, GWL_WNDPROC,
                               (LONG)ProcessCustomDraw);
          
            }
        }
        return 0;
...
My dilemma in the Callback function is that I should probably return CDRF_NOTIFYITEMDRAW and
CallWindowProc (OldList, hwnd, msg, wParam, lParam) ; also, so I dont know how to go about it.
I guess that's why it crashes.

Code:
LRESULT CALLBACK ProcessCustomDraw(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;

    switch(lplvcd->nmcd.dwDrawStage)
    {
    case CDDS_PREPAINT:  //Before the paint cycle begins
        /* Need to process this case and set
           pResult to CDRF_NOTIFYITEMDRAW,
           otherwise parent will never receive
           CDDS_ITEMPREPAINT notification. (GGH)*/
        return CDRF_NOTIFYITEMDRAW;
     
    case CDDS_ITEMPREPAINT: //Before item is drawn
    {
        int row = lplvcd->nmcd.dwItemSpec;
        if(row%2 == 0)
        {
            lplvcd->clrText   = RGB(255,200,255);
            lplvcd->clrTextBk = RGB(24,226,23);
        }
        return CDRF_DODEFAULT;
    
    }
    }

    return CallWindowProc (OldList, hwnd, msg, wParam, lParam) ;
}