CListCtrl的OnNMCustomdraw为什么总是执行CDDS_PREPAINT
voidCMyListCtrlNew::OnNMCustomdraw(NMHDR*pNMHDR,LRESULT*pResult){NMLVCUSTOMDRAW*pLVCD...
void CMyListCtrlNew::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
switch (pLVCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT: //总是执行这一选项
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case pLVCD->nmcd.dwDrawStage:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
{
COLORREF crText, crBkgnd;
if ( 0 == pLVCD->iSubItem )
{
crText = RGB(255,0,0);
crBkgnd = RGB(128,128,255);
}
else if ( 1 == pLVCD->iSubItem )
{
crText = RGB(0,255,0);
crBkgnd = RGB(255,0,0);
}
else
{
crText = RGB(128,128,255);
crBkgnd = RGB(0,0,0);
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
break;
}
}
}
第二个case写错了,应该是case CDDS_ITEMPREPAINT: 展开
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
switch (pLVCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT: //总是执行这一选项
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case pLVCD->nmcd.dwDrawStage:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
{
COLORREF crText, crBkgnd;
if ( 0 == pLVCD->iSubItem )
{
crText = RGB(255,0,0);
crBkgnd = RGB(128,128,255);
}
else if ( 1 == pLVCD->iSubItem )
{
crText = RGB(0,255,0);
crBkgnd = RGB(255,0,0);
}
else
{
crText = RGB(128,128,255);
crBkgnd = RGB(0,0,0);
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
break;
}
}
}
第二个case写错了,应该是case CDDS_ITEMPREPAINT: 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
2009-12-31
展开全部
我也不知道哪里错了,是要改变listctrl的文字颜色吗?
codeproject上有一个例子,很好的,我就是参照那个写的
名字是Neat Stuff to Do in List Controls Using Custom Draw,你在google你搜一下吧
codeproject上有一个例子,很好的,我就是参照那个写的
名字是Neat Stuff to Do in List Controls Using Custom Draw,你在google你搜一下吧
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询