void CDSelect::OnNMCustomdrawLcselect(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = CDRF_DODEFAULT;
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
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.
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
//字体颜色
COLORREF crText = RGB(0,100,240);
if (_T("0") == m_LCselect.GetItemText(nItem,6))
{
crText = RGB(200,200,200);
}
pLVCD->clrText = crText;
//高亮颜色
/*
if( m_LCselect.GetItemState(nItem, CDIS_SELECTED) )
{ // 预留BUG,看有多少人是摘自这里, CDIS_SELECTED前少取反号,且把异或为与
pLVCD->nmcd.uItemState ^= CDIS_SELECTED;// 预留BUG
//pLVCD->nmcd.uItemState = CDIS_SELECTED;
pLVCD->clrTextBk =RGB(0, 0, 120);
//pLVCD->clrText = RGB(0, 0, 255);
*pResult = CDRF_NEWFONT;
//return;
}
*/
/*
if( m_LCselect.GetItemState(nItem, LVIS_SELECTED) == LVIS_SELECTED )
{
pLVCD->clrTextBk =RGB(255, 0, 0);
*pResult = CDRF_NEWFONT;
return;
}
*/
/*
POSITION pos = m_LCselect.GetFirstSelectedItemPosition();
int ntpItem = 0;
if (pos == NULL)
return;
else
{
while (pos)
{
int ntpItem = m_LCselect.GetNextSelectedItem(pos);
//TRACE1("Item %d was selected!/n", nItem);
// you could do your own processing on nItem here
}
}
*/
/*
if (pLVCD->nmcd.uItemState == CDIS_FOCUS)
{
// pLVCD->clrText = RGB(255,0,0);
pLVCD->clrTextBk = RGB(255,0,0);
*pResult = CDRF_NEWFONT;
return;
}
*/
/*
if ( (pLVCD->nmcd.dwItemSpec % 3) == 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.
// Tell Windows to paint the control itself.
*/
*pResult = CDRF_DODEFAULT;
//return;
}
if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
// This is the prepaint stage for a subitem. Here's where we set the
// item's text and background colors. Our return value will tell
// Windows to draw the subitem itself, but it will use the new colors
// we set here.
// The text color will cycle through red, green, and light blue.
// The background color will be light blue for column 0, red for
// column 1, and black for column 2.
COLORREF crText;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
if ( m_LCselect.GetItemText (nItem,6) == _T("0"))
{
crText = RGB(255,0,0);
}
// Store the colors back in the NMLVCUSTOMDRAW struct.
pLVCD->clrText = crText;
//pLVCD->clrTextBk = crBkgnd;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
//高亮颜色设置
/*
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
// This is the prepaint stage for a subitem. Here's where we set the
// item's text and background colors. Our return value will tell
// Windows to draw the subitem itself, but it will use the new colors
// we set here.
// Store the colors back in the NMLVCUSTOMDRAW struct.
int nItem=(int)(pLVCD->nmcd.dwItemSpec);
if((m_LCselect.GetItemState(nItem, LVIS_SELECTED)==LVIS_SELECTED)){
//pLVCD->clrText = RGB(255,155,255);
pLVCD->clrTextBk = RGB(10,80,10);
}
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
*/
//*pResult = 0;
}