www.pudn.com > TCPIPAnalyse1.rar > IrisAnalyseViewL.cpp
// IrisAnalyseViewL.cpp : implementation of the CIrisAnalyseViewL class
//
#include "stdafx.h"
#include "IrisAnalyse.h"
#include "IrisAnalyseDoc.h"
#include "IrisAnalyseViewL.h"
//#include "OpenFileDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIrisAnalyseViewL
IMPLEMENT_DYNCREATE(CIrisAnalyseViewL, CListView)
BEGIN_MESSAGE_MAP(CIrisAnalyseViewL, CListView)
//{{AFX_MSG_MAP(CIrisAnalyseViewL)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIrisAnalyseViewL construction/destruction
CIrisAnalyseViewL::CIrisAnalyseViewL()
{
// TODO: add construction code here
m_nFileLength = 0;
}
CIrisAnalyseViewL::~CIrisAnalyseViewL()
{
}
BOOL CIrisAnalyseViewL::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
if (!CListView::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.style |= LVS_REPORT;
//AfxMessageBox("PreCreateWindow");
return TRUE;
//return CListView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CIrisAnalyseViewL drawing
void CIrisAnalyseViewL::OnDraw(CDC* pDC)
{
CIrisAnalyseDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
AfxMessageBox("OnDraw");
m_nFileLength = pDoc->GetDataLen();
// TODO: add draw code for native data here
char temp1[20];
// pDoc->GetDataToDisp(temp1);
AfxMessageBox(temp1);
}
CIrisAnalyseDoc* CIrisAnalyseViewL::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIrisAnalyseDoc)));
return (CIrisAnalyseDoc*)m_pDocument;
}
void CIrisAnalyseViewL::OnInitialUpdate()
{
//CListView::OnInitialUpdate();
//CIrisAnalyseDoc* pDoc = GetDocument();
// TODO: You may populate your ListView with items by directly accessing
// its list control through a call to GetListCtrl().
CListCtrl& lc = GetListCtrl();
//AfxMessageBox("OnInitialUpdate");
//get a colour line
::SendMessage(lc.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
// Add a couple of columns
int i;
static LV_COLUMN cols[5] =
{
{ LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH, 0, 50, "NO"},
{ LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH, 0, 100, "MAC"},
{ LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH, 0, 100, "IP" },
{ LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH, 0, 50, "TCP" },
{ LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH, 0,250, "DATA" },
};
const int NUMCOLS = sizeof(cols)/sizeof(cols[0]);
for(i = 0; iSetWindowText("hello");
CIrisAnalyseDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CListCtrl& lcl = GetListCtrl();
//////////////////////////////////////
//save Iris vertion
char temp2[20];
strcpy(temp2,(char *)pDoc->m_sHead.buff);
TCPIPPKG *pl,*p;
//point to left data
pl=pDoc->m_pLeftDataHead;
p=pDoc->m_pRightDataHead;
//////////////////////////////////////////
//insert subitem
int i;
CString s;
for(i=0;pl!=NULL;i++)
{
//return data length
unsigned char temp[100][48];
//display left no
s.Format("[%d]",pl->Num);//NoLeft);
lcl.InsertItem(i,s);
//if data without above of two line
if( (pl->nLine==0) || (pl->nLine==1) )
{
//display left mac srcaddr
int nRetMac=pDoc->HexToAscll(&temp[0][0],
pl->macpkg.SrcAddr,6);
lcl.SetItemText(i,1,(char*)temp);
//display left ip srcip
CString iptemp;
iptemp.Format(TEXT(" %d.%d.%d.%d"),
pl->ippkg.srcIP[0],
pl->ippkg.srcIP[1],
pl->ippkg.srcIP[2],
pl->ippkg.srcIP[3]);
lcl.SetItemText(i,2,iptemp);
//display left tcp srcport
if (pl->tcppkg.SrcPort == 0)
{
lcl.SetItemText(i,3,"[-----]");//ARP ----add by chenjw
}
else
{
CString tcptemp;
tcptemp.Format(TEXT("%d"),pl->tcppkg.SrcPort);
lcl.SetItemText(i,3,tcptemp);
}
//display left useful data
if(pl->DataLen!=0)
{
int nRetData=pDoc->HexToAscll(&temp[0][0],
pl->databuff,
pl->DataLen);
lcl.SetItemText(i,4,(char*)temp);
}
else
{
if (pl->tcppkg.SrcPort == 0)
{
lcl.SetItemText(i,4,"[-----]");//APR---add by chenjw
}
else
{
lcl.SetItemText(i,4,"[NULL]");//no data
}
}
}
//have many line data
else
{
int j;
int nRetMac=pDoc->HexToAscll(&temp[0][0],
pl->macpkg.SrcAddr,6);
lcl.SetItemText(i,1,(char*)temp);
CString iptemp;
iptemp.Format(TEXT(" %d.%d.%d.%d"),
pl->ippkg.srcIP[0],
pl->ippkg.srcIP[1],
pl->ippkg.srcIP[2],
pl->ippkg.srcIP[3]);
lcl.SetItemText(i,2,iptemp);
CString tcptemp;
tcptemp.Format(TEXT("%d"),pl->tcppkg.SrcPort);
lcl.SetItemText(i,3,tcptemp);
int nRetData=pDoc->HexToAscll(&temp[0][0],
pl->databuff,
pl->DataLen);
lcl.SetItemText(i,4,(char*)&temp[0][0]);
for(j=1;jHexToAscll(&temp[0][0],
pl->databuff,
pl->DataLen);
lcl.SetItemText(i+j,4,(char*)&temp[j][0]);
}
//return i value
i+=pl->nLine-1;
}
pl=pl->next;
}
return 0;
}
//////////////////////////////////////////
//主窗口背景色
BOOL CIrisAnalyseViewL::OnEraseBkgnd(CDC* pDC)
{
/*===========
// TODO: Add your message handler code here and/or call default
// Create a pruple brush.
CBrush Brush (RGB (0 , 128 , 128) );
// Select the brush into the device context .
CBrush* pOldBrush = pDC->SelectObject(&Brush);
// Get the area that needs to be erased .
CRect reClip;
pDC->GetClipBox(&reClip);
//Paint the area.
pDC-> PatBlt (reClip.left , reClip.top , reClip.Width ( ) , reClip.Height( ) , PATCOPY );
//Unselect brush out of device context .
pDC->SelectObject (pOldBrush );
// Return nonzero to half fruther processing .
===============================*/
return CListView::OnEraseBkgnd(pDC);
}