昨天晚上就把SSDT查看/恢复工具编写完毕,但美中不足的是,对于修改过的SSDT项在用CListCtrl列出来后,无法修改指定这行的颜色!郁闷中,今天下午起来又继续找方法,最后终于找到了,我的工具也可以说是圆满结束了!
首先是添加以下消息
ON_NOTIFY( NM_CUSTOMDRAW, IDC_LIST1, OnDrawColorForMyList ) //为改变颜色添加的消息
再添加类成员函数,就OK了:
//改变 m_List 控件单行的颜色
void CSSDTDlg::OnDrawColorForMyList( NMHDR *pNmHdr, LRESULT *pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast
*pResult = CDRF_DODEFAULT;
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 )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast
//如果当前SSDT地址与原始地址不一样,则显示字体为红色,否则为黑色
if( /
((pSSDTSaveTable)((ULONG)pSSDTST + nItem * sizeof(SSDTSaveTable)))->ulCurrentFunctionAddress /
!= ((pSSDTSaveTable)((ULONG)pSSDTST + nItem * sizeof(SSDTSaveTable)))->ulOriginalFunctionAddress /
) //设置为红色
{
clrNewTextColor = RGB( 255, 0, 0 );
}
else //设置为黑色
{
clrNewTextColor = RGB( 0, 0, 0 );
}
//设置背景色
if( nItem%2 ==0 )
{
clrNewBkColor = RGB( 240, 240, 240 ); //偶数行背景色为灰色
}
else
{
clrNewBkColor = RGB( 255, 255, 255 ); //奇数行背景色为白色
}
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
*pResult = CDRF_DODEFAULT;
}
}
高亮及取消高亮
m_List.SetItemState(0,LVIS_DROPHILITED,LVIS_DROPHILITED);
UINT nState=m_List.GetItemState(1,LVIF_STATE);
nState&=!nState;
m_List.SetItemState(1,nState,LVIF_STATE);