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

📄 file_handleview.cpp

📁 匿名通信代码
💻 CPP
字号:
// file_handleView.cpp : implementation of the CFile_handleView class
//

#include "stdafx.h"
#include "file_handle.h"

#include "file_handleDoc.h"
#include "file_handleView.h"
#include "list.h" 

#include <pcap.h>
#include <remote-ext.h>
#include <winsock.h>

#include "data.h"

#pragma comment(lib,"wsock32")

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView

IMPLEMENT_DYNCREATE(CFile_handleView, CView)

BEGIN_MESSAGE_MAP(CFile_handleView, CView)
//{{AFX_MSG_MAP(CFile_handleView)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView construction/destruction

CFile_handleView::CFile_handleView()
{
	// TODO: add construction code here
	
}

CFile_handleView::~CFile_handleView()
{
}

BOOL CFile_handleView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView drawing

void CFile_handleView::OnDraw(CDC* pDC)
{
	CFile_handleDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	
	// TODO: add draw code for native data here

	UINT position = 10;
	int m=370,n=500;
	for(int x=0;x<28;x++)
	{
		CPen pen;
		pen.CreatePen(PS_DASH,x*1.2,RGB(245,120,225));
		CPen *oldPen = pDC->SelectObject(&pen);
		position += x*2+5;
		pDC->MoveTo(m,position);
		pDC->LineTo(n,position);
		pDC->SelectObject(oldPen);
		m=m-20;
		n=n-20;
	}
	
}

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView printing

BOOL CFile_handleView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CFile_handleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CFile_handleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView diagnostics

#ifdef _DEBUG
void CFile_handleView::AssertValid() const
{
	CView::AssertValid();
}

void CFile_handleView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CFile_handleDoc* CFile_handleView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFile_handleDoc)));
	return (CFile_handleDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFile_handleView message handlers

int CFile_handleView::OnFileOpen() 
{
	// TODO: Add your command handler code here
	
    list ldlg;
	char errbuf[PCAP_ERRBUF_SIZE];
	CString   lpszFilter;  ///file filter
	lpszFilter   =   "Libpcap Files (*.dump)|*.dump|All Files (*.*)|*.*|"; 
	//lpszFilter   =   "Libpcap Files(*.dump;*.cap;*.cap.gz)|*.dump;*.cap;*.cap.gz|";
	CFileDialog   dlg(true, 0, 0, OFN_HIDEREADONLY | OFN_EXPLORER | OFN_OVERWRITEPROMPT, 
		lpszFilter, 0); ///TRUE为OPEN对话框,FALSE为SAVE AS对话框
    
	if(dlg.DoModal()==IDOK)
	{
		ldlg.FilePathName=dlg.GetPathName();
		if((ldlg.fp = pcap_open_offline(ldlg.FilePathName,errbuf)) == NULL)
		{
			MessageBox("Please choose the right file!","Error",MB_ICONWARNING | MB_OK);
			return -1;
		}
		ldlg.DoModal();
	}
	
	return 1;	
}

⌨️ 快捷键说明

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