i'm working on win32 listview controls,Want to achieve CustomDraw,
but i got something strange。 I wonder why this dwDrawStage value is always equal to 1
bool rst = CreateWinEx(WC_LISTVIEW, NULL,
WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_EDITLABELS | LVS_NOCOLUMNHEADER | WS_BORDER,0,
x,y,w,h,
hwndParent_, NULL, GetModuleHandle(NULL));
OnListViewNotify
LRESULT my::listView::OnListViewNotify(HWND hwnd,LPARAM lParam)
{
NMLISTVIEW* pnmv= (NMLISTVIEW*)lParam;
LRESULT lResult = 0;
switch(pnmv->hdr.code)
{
case NM_CUSTOMDRAW:
{
idebug("NM_CUSTOMDRAW\n");
SetWindowLong(hWnd, DWL_MSGRESULT, (LONG)CustomDraw(lParam));
return TRUE;
}
break;
}
return(lResult);
}
CustomDraw
LRESULT my::listView::CustomDraw( LPARAM lParam )
{
//NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW) lParam;
idebug("dwDrawStage:%d\n",pLVCD->nmcd.dwDrawStage);
switch(pLVCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
{
//request notifications for individual listview items
return CDRF_NOTIFYITEMDRAW;
}
case CDDS_ITEMPREPAINT: //Before an item is drawn
{
return CDRF_NOTIFYSUBITEMDRAW;
}
case CDDS_SUBITEM | CDDS_ITEMPREPAINT: //Before a subitem is drawn
{
switch(pLVCD->iSubItem)
{
case 0:
{
pLVCD->clrText = RGB(255,255,255);
pLVCD->clrTextBk = RGB(240,55,23);
return CDRF_NEWFONT;
}
case 1:
{
pLVCD->clrText = RGB(255,255,0);
pLVCD->clrTextBk = RGB(0,0,0);
return CDRF_NEWFONT;
}
}
}
}
return CDRF_DODEFAULT;
}
Want to achieve CustomDraw,but i got something strange。 I wonder why this dwDrawStage value is always equal to 1
info from debugging
hdr.code->NM_CUSTOMDRAW
dwDrawStage:1
thank you for sharing you wisdom and experience;
the key is about return value as @Adrian Mole say.
when i return CDRF_NEWFONT or return CDRF_NOTIFYITEMDRAW the proplem was disappear.