本文介绍了如何根据MFC中CListCtrl的单元格值来获取一行CListCtrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下处理程序来突出显示一行但是在这里我无法根据CListCtrl的单元格值进行突出显示。请非常紧急。
以下是CListCtrl的指针。
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.
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;
}
}
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
推荐答案
这篇关于如何根据MFC中CListCtrl的单元格值来获取一行CListCtrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!