// Take the default processing unless we set this to something else below. *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 notification message for an item. We'll request // notifications before each subitem's prepaint stage.
void fun(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*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 notification message for an item. We'll request
// notifications before each subitem's prepaint stage.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
COLORREF clrNewTextColor, clrNewBkColor; HTREEITEM nItem = (HTREEITEM)( pLVCD->nmcd.dwItemSpec );
BOOL bSelect = FALSE;
HTREEITEM selitem = m_TreeTest.GetSelectedItem();
if (selitem==nItem)
bSelect = TRUE;
if(bSelect)
{
clrNewTextColor = RGB(255,255,255); //Set the text to red
clrNewBkColor = RGB(49,106,197); //Set the bkgrnd color to blue
}
else
{
clrNewTextColor = RGB(0,0,0); //Leave the text black
clrNewBkColor = RGB(255,255,255); //leave the bkgrnd color white
}
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}