【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-TrapView.cpp,希望本篇文章对您学习有所帮助。
// TrapView.cpp : implementation of the CTrapView class
//
#include "stdafx.h"
#include "Trap.h"
#include "TrapDoc.h"
#include "TrapView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTrapView
IMPLEMENT_DYNCREATE(CTrapView, CFormView)
BEGIN_MESSAGE_MAP(CTrapView, CFormView)
//{{AFX_MSG_MAP(CTrapView)
ON_COMMAND(ID_START, OnStart)
ON_COMMAND(ID_END, OnEnd)
ON_COMMAND(ID_FINISH, OnFinish)
ON_COMMAND(ID_CONFIG, OnConfig)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
// Standard printing commands
// ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
// ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
// ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTrapView construction/destruction
CTrapView::CTrapView()
: CFormView(CTrapView::IDD)
{
//{{AFX_DATA_INIT(CTrapView)
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CTrapView::~CTrapView()
{
}
void CTrapView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTrapView)
DDX_Control(pDX, IDC_LIST1, m_list1);
DDX_Control(pDX, IDC_EDIT1, m_text);
DDX_Control(pDX, IDC_TREE1, m_tree);
//}}AFX_DATA_MAP
}
BOOL CTrapView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CTrapView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
// m_hIcon=AfxGetApp()->LoadIcon(IDI_ICON1);;
//pMain->pTrapView=this;
TrapMessage="";
m_list1.InsertColumn(0," 类型 ",LVCFMT_LEFT,80,0);
m_list1.InsertColumn(1," 名称(DLCI)",LVCFMT_LEFT,130,1);
m_list1.InsertColumn(2," 状态 ",LVCFMT_LEFT,70,2);
m_list1.InsertColumn(3," 辅助信息 ",LVCFMT_LEFT,300,3);
m_list1.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_tree.InsertItem("被监视设备",NULL);
m_tree.SetIndent(32);
m_tree.SetItemHeight(26);
// m_tree.InsertItem("aaa",m_tree.GetRootItem());
m_iImageList.Create(16, 16, TRUE,1, 0);
HICON hIcon;
hIcon= NULL;
//0,root;
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ROUTER), IMAGE_ICON, 32, 32, 0);
m_iImageList.Add(hIcon);
//1,closed box;
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_LINE), IMAGE_ICON, 16, 16, 0);
m_iImageList.Add(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_DOWN), IMAGE_ICON, 16, 16, 0);
m_iImageList.Add(hIcon);
m_tree.SetImageList (&m_iImageList,TVSIL_NORMAL);
dlg.Create(IDD_DIALOG1);
Recive=true;
}
/////////////////////////////////////////////////////////////////////////////
// CTrapView printing
BOOL CTrapView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTrapView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTrapView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CTrapView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CTrapView diagnostics
#ifdef _DEBUG
void CTrapView::AssertValid() const
{
CFormView::AssertValid();
}
void CTrapView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CTrapDoc* CTrapView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTrapDoc)));
return (CTrapDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTrapView message handlers
//回调函数,当有TRAP到达时,调用该函数进行进一步处理;
void callme (int reason, Snmp *snmp, Pdu &pdu, SnmpTarget &target, void *cd)
{
CString str="";
CTime time=CTime::GetCurrentTime();
CStri