⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message.cpp

📁 数据加密算法
💻 CPP
字号:
#include "pch.h"
#include "util.h"
#include "main.h"
#include "doc.h"
#include "debug.h"
#include "message.h"
#include "record.h"
#include "watch.h"

IMPLEMENT_DYNCREATE ( CMessageView , CListView )

BEGIN_MESSAGE_MAP ( CMessageView , CListView )
	ON_NOTIFY_REFLECT ( NM_DBLCLK, OnDblclk )
	ON_WM_CREATE ( ) 
	ON_WM_KILLFOCUS ( )
	ON_COMMAND ( IDM_VIEW_WATCH , OnViewWatch )
	ON_UPDATE_COMMAND_UI ( IDM_VIEW_WATCH , OnUpdateViewWatch )
END_MESSAGE_MAP ( )

CMessageView::CMessageView ( )
{
}

CMessageView::~CMessageView ( )
{
}

CDancerDoc* CMessageView::GetDocument ( )
{
	return ( CDancerDoc* ) CView::GetDocument ( ) ;
}

void CMessageView::OnInitialUpdate ( )
{
	CListView::OnInitialUpdate ( ) ;

	GetDocument ( )->m_pMessageView = this ;
}

int CMessageView::OnCreate ( LPCREATESTRUCT lpCreateStruct )
{
	if ( -1 == CListView::OnCreate ( lpCreateStruct ) )
		return -1 ;

	CListCtrl& ctrl = GetListCtrl ( ) ; 

	SetWindowLong (
		ctrl.GetSafeHwnd ( ) ,
		GWL_STYLE ,
		WS_CHILD |
		WS_VISIBLE |
		LVS_REPORT |
		LVS_SINGLESEL |
		LVS_OWNERDRAWFIXED ) ;

	xInsertColumn ( ctrl , 0 , IDS_INDEX , 60 ) ;
	xInsertColumn ( ctrl , 1 , IDS_DEPTH , 60 ) ;
	xInsertColumn ( ctrl , 2 , IDS_IMPORT , 100 ) ;
	xInsertColumn ( ctrl , 3 , IDS_EXPORT , 100 ) ;
	xInsertColumn ( ctrl , 4 , IDS_FUNCTION , 160 ) ;
	xInsertColumn ( ctrl , 5 , IDS_ENTER , 80 ) ;
	xInsertColumn ( ctrl , 6 , IDS_LEAVE , 80 ) ;
	xInsertColumn ( ctrl , 7 , IDS_RETURN , 80 ) ;

	return 0 ;
}

void CMessageView::DrawItem ( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CListCtrl& ctrl = GetListCtrl ( ) ;
	Record* p = ( Record* ) lpDrawItemStruct->itemData ;
	int i , s , w [ 8 ] ;
	CRect rc [ 8 ] , 
		r = lpDrawItemStruct->rcItem ;
	LOGFONT lf ;
	CBrush br ;
	CFont fnt ;
	CDC dc ;

	dc.Attach ( lpDrawItemStruct->hDC ) ;
	
	s = r.left ; 
	for ( i = 0 ; i < 8 ; i++ )
	{
		w [ i ] = ctrl.GetColumnWidth ( i ) ;
		rc [ i ].top = r.top ;
		rc [ i ].bottom = r.bottom ;
		rc [ i ].left = s + 2 ;

		s += w [ i ] ;
		rc [ i ].right = s - 2 ;
	}

	if ( lpDrawItemStruct->itemState & ODS_SELECTED )
	{
		dc.SetTextColor ( GetSysColor ( COLOR_HIGHLIGHTTEXT ) ) ;
		br.CreateSysColorBrush ( COLOR_HIGHLIGHT ) ;
	}
	else
	{
		dc.SetTextColor ( ctrl.GetTextColor ( ) ) ;
		br.CreateSolidBrush ( ctrl.GetBkColor ( ) ) ;
	}

	dc.FillRect ( &r , &br ) ;

	CString msg ;

	if ( p->m_nType != HOOK_MSG )
	{
		if ( ( lpDrawItemStruct->itemState & ODS_SELECTED ) == 0 )
		{
			if ( p->m_nType == EXTRA_MSG )
			{
				dc.SetTextColor ( RGB ( 0 , 128 , 0 ) ) ;
			}
			else
			{
				dc.SetTextColor ( RGB ( 0, 0 , 128 ) ) ;
			}
		}

		CMainApp* pp = ( CMainApp* ) AfxGetApp ( ) ;
		pp->m_imgMessage.Draw ( 
			&dc , 
			( int ) p->m_nIconID , 
			r.TopLeft ( ) , 
			ILD_TRANSPARENT ) ;

		p->Present ( msg ) ;

		r.left += 18 ;
		dc.DrawText ( msg , &r , DT_VCENTER | DT_LEFT ) ;
	}
	else
	{
		if ( p->m_pDispatch->m_bExport == TRUE )
		{
			ctrl.GetFont ( )->GetLogFont ( &lf ) ;

			lf.lfWeight = FW_BOLD ;
			fnt.CreateFontIndirect ( &lf ) ;
			dc.SelectObject ( &fnt ) ;
		}

		msg.Format ( "%d" , lpDrawItemStruct->itemID ) ;
		dc.DrawText ( msg , rc , DT_VCENTER | DT_LEFT ) ;

		msg.Format ( "%d" , p->m_pDispatch->m_dwDepth ) ;
		dc.DrawText ( msg , rc + 1 , DT_VCENTER | DT_LEFT ) ;

		dc.DrawText ( p->m_pDispatch->m_strImportName , rc + 2 , DT_VCENTER | DT_LEFT ) ;
		dc.DrawText ( p->m_pDispatch->m_strExportName , rc + 3 , DT_VCENTER | DT_LEFT ) ;

		p->Present ( msg ) ;
		dc.DrawText ( msg , rc + 4 , DT_VCENTER | DT_LEFT ) ;

		xTranslateTime ( p->m_pDispatch->m_dwTime1 , msg ) ;
		dc.DrawText ( msg , rc + 5 , DT_VCENTER | DT_LEFT ) ;

		if ( p->m_pDispatch->m_bPending == TRUE )
		{
			msg.LoadString ( IDS_CALLING ) ;
			dc.DrawText ( msg , rc + 6 , DT_VCENTER | DT_LEFT ) ;
		}
		else
		{
			xTranslateTime ( p->m_pDispatch->m_dwTime2 , msg ) ;
			dc.DrawText ( msg , rc + 6 , DT_VCENTER | DT_LEFT ) ;

			if ( p->m_pDispatch->m_bPostInvalid == FALSE )
			{
				msg.Format ( "%08x" , p->m_pDispatch->m_dwReturn ) ;
				dc.DrawText ( msg , rc + 7 , DT_VCENTER | DT_LEFT ) ;
			}
			else
			{
				msg.LoadString ( IDS_INVALID ) ;
				dc.DrawText ( msg , rc + 7 , DT_VCENTER | DT_LEFT ) ;
			}
		}
	}
	dc.Detach ( ) ;
}

void CMessageView::OnViewWatch ( )
{
	CWatchDialog* p = new CWatchDialog ( GetDocument ( ) , FALSE ) ;
	p->DoModal ( ) ;
	delete p ;
}

void CMessageView::OnUpdateViewWatch ( CCmdUI* pCmdUI )
{
	if ( GetDocument ( )->m_pDebugControl->IsDebugging ( ) &&
		 !GetDocument ( )->m_pDebugControl->IsPaused ( ) )
	{
		pCmdUI->Enable ( FALSE ) ;
	}
	else
	{
		CListCtrl& ctrl = GetListCtrl ( ) ;
		int item = ctrl.GetNextItem ( -1 , LVNI_SELECTED ) ;

		if ( item != -1 )
		{
			Record* p = ( Record* ) ctrl.GetItemData ( item ) ;
			pCmdUI->Enable ( p->m_nType == HOOK_MSG ) ;
		}
		else
		{
			pCmdUI->Enable ( FALSE ) ;
		}
	}
}

void CMessageView::OnDblclk ( NMHDR* pNMHDR, LRESULT* pResult )
{
	LPNMITEMACTIVATE lpNMItemActivate = ( LPNMITEMACTIVATE ) pNMHDR ;
	CListCtrl& ctrl = GetListCtrl ( ) ;

	Record* p = ( Record* ) ctrl.GetItemData ( lpNMItemActivate->iItem ) ;
	if ( p->m_nType == HOOK_MSG )
	{
		OnViewWatch ( ) ;
	}
	
	*pResult = 0 ;
}

void CMessageView::DeselectAll ( )
{
	CListCtrl& ctrl = GetListCtrl ( ) ;
	ctrl.SetItemState ( -1 , 0 , LVIS_SELECTED ) ;
}

void CMessageView::OnKillFocus ( CWnd* pNewWnd )
{
	DeselectAll ( ) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -