[英]win32 ListView CustomDraw , why dwDrawStage value is alway equal to 1
i'm working on win32 listview controls,Want to achieve CustomDraw,我正在研究 win32 列表视图控件,想要实现 CustomDraw,
but i got something strange。 I wonder why this dwDrawStage value is always equal to 1但我有一些奇怪的事情。我想知道为什么这个dwDrawStage值总是等于 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想实现CustomDraw,但是我得到了一些奇怪的东西。我想知道为什么这个dwDrawStage值总是等于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.正如@Adrian Mole 所说,关键是关于返回值。
when i return CDRF_NEWFONT or return CDRF_NOTIFYITEMDRAW the proplem was disappear.当我返回 CDRF_NEWFONT 或返回 CDRF_NOTIFYITEMDRAW 时,问题消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.