[英]No color in CListCtrl report view
I have done this before but to my surprise the CListCtrl will not show the text in color. 我之前已经做过,但是令我惊讶的是CListCtrl不会以彩色显示文本。 I have the list view control on a dialog.
我在对话框上有列表视图控件。 I am using VS2010, is there something else needed that I am missing?
我正在使用VS2010,是否还需要其他一些东西?
void CGameView::OnCustomdrawListBatsmen(NMHDR *pNMHDR, LRESULT *pResult)
{
//LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
LPNMLVCUSTOMDRAW pNMLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
*pResult = CDRF_DODEFAULT;
switch( pNMLVCD->nmcd.dwDrawStage )
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
pNMLVCD->clrTextBk = RGB(255,0,0);
pNMLVCD->clrText = RGB(255, 0, 0 );
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
// if( pNMLVCD->iSubItem == 1 )
pNMLVCD->clrTextBk = RGB(0,255,0);
pNMLVCD->clrText = RGB(255, 0, 0 );
break;
}
*pResult = 0;
}
When I debug it, the control never even get passed the first case! 当我调试它时,该控件甚至永远不会通过第一种情况! I don't know is that?
我不知道吗 Do I need to set List control properties in resource view?
我是否需要在资源视图中设置列表控件属性?
maybe, in CGameView, add: 也许在CGameView中添加:
1. 1。
ON_NOTIFY(LVN_GETDISPINFO, IDC_LIST_Batsmen, GetDispInfo)
2. 2。
void CGameView::GetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
in your CListCtrl class, add: 在您的CListCtrl类中,添加:
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdrawListBatsmen)
I fixed the issue, it was the last line: 我解决了这个问题,这是最后一行:
*pResult = 0;
This needed to be removed because it was resetting the whatever value was being set in the switch case. 需要删除它,因为它正在重置开关盒中设置的任何值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.