Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following handler to highlight a row but here i am not able to highlight based on cell value of a CListCtrl. please its very urgent.

this following is the pointer for CListCtrl.

C++
CListCtrl *ptrListHistory;

afx_msg void OnNMCustomdrawListHistory(NMHDR *pNMHDR, LRESULT *pResult);

void CCylanceCollectDlg::OnNMCustomdrawListHistory(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMLVCUSTOMDRAW pLVCD = reinterpret_cast<lpnmlvcustomdraw>(pNMHDR);
    
    *pResult = CDRF_DODEFAULT;
    
    switch(pLVCD->nmcd.dwDrawStage)
    {
        case CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;
        
        case CDDS_ITEMPREPAINT:
        {
            /*COLORREF crText;
            if ( (pLVCD->nmcd.dwItemSpec) == 0 )
            crText = RGB(0,0,255);*/
            /*else if ( (pLVCD->nmcd.dwItemSpec % 3) == 1 )
            crText = RGB(0,255,0);*/
            
            
            // Store the color back in the NMLVCUSTOMDRAW struct.
            /*pLVCD->clrText = crText;*/
            
            // Tell Windows to paint the control itself.
            *pResult = CDRF_NOTIFYPOSTPAINT;
        }
        break;
        
        case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
        {
            LVITEM rItem;
            int    nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
            
            ZeroMemory ( &rItem, sizeof(LVITEM) );
            rItem.mask  = LVIF_IMAGE | LVIF_STATE;
            rItem.iItem = nItem;
            rItem.stateMask = LVIS_SELECTED;
            ptrListHistory->GetItem(&rItem);//.GetItem ( &rItem );
            
            
            *pResult = CDRF_NEWFONT;
            return;
            //if(lpLVCustomDraw->iSubItem == 1)
            //{
            ////if(lpLVCustomDraw->nmcd.lItemlParam)
            //{
            //   lpLVCustomDraw->clrText = RGB(255, 0, 0);
            //  }
            //}
            // *pResult = CDRF_NEWFONT;
            //            return;
        }
        default:
            break;
    }
}



CSS
My problem is i want to highlight a row based on the cell value of CListCtrl.

for example

I have the following rows in my listcontrol

SNo                  URl                                  LastVisitDate

1      https://accounts.google.com/ServiceLoginAuth       20/03/2014 11:22:57

2      https://accounts.google.com/ServiceLoginAuth       20/03/2014 11:22:39

3      https://accounts.google.com/ServiceLoginAuth       20/03/2014 11:22:16

4      https://accounts.google.com/ServiceLoginAuth       20/03/2014 11:22:07

So from the above rows I want highlight a row when i clicked on tree node  based on the recent LastVisitDate value in CListCtrl in the mfc application
Posted
Updated 20-Mar-14 0:36am
v3
Comments
Richard MacCutchan 20-Mar-14 6:04am    
No, it's not urgent. Also, it would help if you explained exactly what is not working.
Jochen Arndt 20-Mar-14 8:45am    
To trigger the CDDS_ITEMPREPAINT | CDDS_SUBITEM case you should return CDRF_NOTIFYSUBITEMDRAW from within CDDS_ITEMPREPAINT. Then you can change the colors in CDDS_ITEMPREPAINT | CDDS_SUBITEM. But note that these colors are not used for hot and selected items. These items will be drawn afterwards by the system.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900