how to change the highlight color of listctrl
-
Hi all, Im using custom draw to change the color or the listctel item. But i cant change the highlight color . how can i get it done. thankx regards GAN
If you want to highlight a particular row, try this in your OnCustomdrawList function:
COLORREF crText, crBkgnd;
if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
if ( (pLVCD->nmcd.dwItemSpec % 3) == 2 )
{
LOGFONT lfFont;
CFont *pFont = GetFont();\_ASSERTE( pFont ); pFont -> GetLogFont( &lfFont ); CFont m\_fBFont; m\_fBFont.CreateFontIndirect( &lfFont ); SelectObject(pLVCD->nmcd.hdc,m\_fBFont); crText = RGB(255,0,0); // sets text color crBkgnd = RGB(255,255,0); // sets text background/highlight color pLVCD->clrText = crText; pLVCD->clrTextBk = crBkgnd; } \*pResult = CDRF\_NEWFONT; }
}
To color the background of a particular column, try this:
if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText,crBkgnd;
if (0 == pLVCD->iSubItem) // for column 0
{
crText = RGB(128,0,225);
crBkgnd = RGB(247,241,202);
}
else
if (1 == pLVCD->iSubItem) //for column 1
{
crText = RGB(0,128,0);
crBkgnd = RGB(247,241,202);
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}_
Fortitudine Vincimus!_
-
If you want to highlight a particular row, try this in your OnCustomdrawList function:
COLORREF crText, crBkgnd;
if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
if ( (pLVCD->nmcd.dwItemSpec % 3) == 2 )
{
LOGFONT lfFont;
CFont *pFont = GetFont();\_ASSERTE( pFont ); pFont -> GetLogFont( &lfFont ); CFont m\_fBFont; m\_fBFont.CreateFontIndirect( &lfFont ); SelectObject(pLVCD->nmcd.hdc,m\_fBFont); crText = RGB(255,0,0); // sets text color crBkgnd = RGB(255,255,0); // sets text background/highlight color pLVCD->clrText = crText; pLVCD->clrTextBk = crBkgnd; } \*pResult = CDRF\_NEWFONT; }
}
To color the background of a particular column, try this:
if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText,crBkgnd;
if (0 == pLVCD->iSubItem) // for column 0
{
crText = RGB(128,0,225);
crBkgnd = RGB(247,241,202);
}
else
if (1 == pLVCD->iSubItem) //for column 1
{
crText = RGB(0,128,0);
crBkgnd = RGB(247,241,202);
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}_
Fortitudine Vincimus!_
-
Hi all, Im using custom draw to change the color or the listctel item. But i cant change the highlight color . how can i get it done. thankx regards GAN
-
how to change the highlight color of listctrl IM ASKING FOR CHANGING HIGHLIGHT COLOR OF THE LISTCTEL -- modified at 8:13 Friday 18th August, 2006
GANsJob wrote:
highlight color of listctrl
A list has many parts - headers, rows or items, columns or subitems.... The text color of each can be changed; the background color (or what you call "
highlight"
color of each individual part can be changed. When you say, "Change the highlight colour of listctrl
please specify which part of the listctrl you mean._
Fortitudine Vincimus!_
-
GANsJob wrote:
highlight color of listctrl
A list has many parts - headers, rows or items, columns or subitems.... The text color of each can be changed; the background color (or what you call "
highlight"
color of each individual part can be changed. When you say, "Change the highlight colour of listctrl
please specify which part of the listctrl you mean._
Fortitudine Vincimus!_
-
When you say, "Change the highlight colour of listctrl please specify which part of the listctrl you mean. Selected item's higlight color