CListCtrl Farbanpassung
-
Hallo Leute,
ich weis, es gibt zu diesem Thema genügend Fragen, aber irgendwie Checke ich das nicht.
Wie kann ich denn die einzelnen Text/Hintergrund Farben eines ClistCtrl unterschiedlich ändern ??
Habe mir auch schon eine seperate Class von CListCtrl abgeleitet, dort gibt es aber eine Funktion OnCostumDraw wie ich hier schon gelesen habe.
Und wie geht es dann weiter, wie bringe ich den Text zum ändern ???
Kann mir jemand helfen ??
Gruß und Danke im voraus
andy_mann
-
Hmmmmm...
habe es nun hingebracht, dass er die Items Farbig macht...
void CStatistikLogdatenDialog::OnNMCustomdrawStatistikLogdatenliste(NMHDR *pNMHDR, LRESULT *pResult) { NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR ); // LPNMCUSTOMDRAW pLVCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); // TODO: Fügen Sie hier Ihren Kontrollbehandlungscode für die Benachrichtigung ein. *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; } 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; COLORREF crBkgnd; if ( (pLVCD->nmcd.dwItemSpec % 3) == 0 ) { crText = RGB(255,0,0); crBkgnd = RGB(255,0,0); } else if ( (pLVCD->nmcd.dwItemSpec % 3) == 1 ) { crText = RGB(0,255,0); crBkgnd = RGB(0,255,0); } else { crText = RGB(128,128,255); crBkgnd = RGB(0,0,255); } // Store the color back in the NMLVCUSTOMDRAW struct. pLVCD->clrText = crText; pLVCD->clrTextBk = crBkgnd; // Tell Windows to paint the control itself. *pResult = CDRF_DODEFAULT; } }Wie kann ich aber jetzt auf ein bestimmtes Item reagieren ??
z.b. wenn ein bestimmtes Wort kommt, soll er es Blau machen..... ???
Gruß
andy_mann