How to set a Textcolor in a CListCtrl
C / C++ / MFC
3
Posts
3
Posters
0
Views
1
Watching
-
Hi community, how can i set a Textcolor in a CListCtrl for each Item? In addiction from an Itemvalue i want to set a different Item's Textcolor! :confused: Any Idea? thanx break;
Use NM_CUSTOMDRAW. Sample for this code will be like this
void MyDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast( pNMHDR );\*pResult = 0; if ( CDDS\_PREPAINT == pLVCD->nmcd.dwDrawStage ) { \*pResult = CDRF\_NOTIFYITEMDRAW; } else if ( CDDS\_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) { \*pResult = CDRF\_NOTIFYSUBITEMDRAW; } else if ( (CDDS\_ITEMPREPAINT | CDDS\_SUBITEM) == pLVCD->nmcd.dwDrawStage ) { //this will get called for each column in list box //you can deter mine column number by pLVCD->iSubItem COLORREF crText, crBkgnd; crText = RGB(0,255,100); crBkgnd = RGB(255,32,11); pLVCD->clrText = crText; pLVCD->clrTextBk = crBkgnd; \*pResult = CDRF\_DODEFAULT; }
}
-
Use NM_CUSTOMDRAW. Sample for this code will be like this
void MyDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast( pNMHDR );\*pResult = 0; if ( CDDS\_PREPAINT == pLVCD->nmcd.dwDrawStage ) { \*pResult = CDRF\_NOTIFYITEMDRAW; } else if ( CDDS\_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) { \*pResult = CDRF\_NOTIFYSUBITEMDRAW; } else if ( (CDDS\_ITEMPREPAINT | CDDS\_SUBITEM) == pLVCD->nmcd.dwDrawStage ) { //this will get called for each column in list box //you can deter mine column number by pLVCD->iSubItem COLORREF crText, crBkgnd; crText = RGB(0,255,100); crBkgnd = RGB(255,32,11); pLVCD->clrText = crText; pLVCD->clrTextBk = crBkgnd; \*pResult = CDRF\_DODEFAULT; }
}