16,466
社区成员
发帖
与我相关
我的任务
分享
void CListCtrlEx::OnCustomdraw ( NMHDR* pNMHDR, LRESULT* pResult )
{
TRACE("OnCustomdraw\n");
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = 0;
// First thing - check the draw stage. If it's the control's prepaint // stage, then tell Windows we want messages for every item.
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
TRACE("CDDS_PREPAINT\n");
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{ // This is the prepaint stage for an item. Here's where we set the
// item's text color. Our return value will tell Windows to draw the
// item itself, but it will use the new color we set here.
// We'll cycle the colors through red, green, and light blue.
COLORREF crText;
if ( (pLVCD->nmcd.dwItemSpec % 3) == 0 )
crText = RGB(255,0,0);
else if ( (pLVCD->nmcd.dwItemSpec % 3) == 1 )
crText = RGB(0,255,0);
else crText = RGB(128,128,255);
// Store the color back in the NMLVCUSTOMDRAW struct.
TRACE("CDDS_ITEMPREPAINT\n");
pLVCD->clrText = crText;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}