hi all, I found a solution, just use the custom draw, do not use a SetRowColor() method. So I just insert new row at top, like this
CArray crRows;
CArray newData;
int nNew = newData.GetCount();
for (int i=0; i<nnew;> // insert new row at top
CString txt = newData.GetAt(i);
myList.InsertItem(0, txt);
// get color, depends on the real data
COLORREF aColor = GetRowColor(txt);
crRows.InsertAt(0, aColor)
// change the rest of list ctrl
}
and then, in custom draw of the list control, I implement like this:
void CExample1Dlg::OnNMCustomdrawList2(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<nmlvcustomdraw*>( pNMHDR );
int nItem = static\_cast (pLVCD->nmcd.dwItemSpec);
pLVCD->clrTextBk = RGB(0, 0, 0); // select background color
\*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.
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.
COLORREF aColor = crText.GetAt(nItem);
pLVCD->clrText = aColor;
\*pResult = CDRF\_DODEFAULT;
}
}
that's all, and it doesn't take any time to change the color (time is almost 0) Thank you everyone :)