📄 ethernetspyglobstatsdlg.cpp
字号:
// EthernetSpyGlobStatsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "packet32.h"
#include "EthernetSpy.h"
#include "EthernetSpyReader.h"
#include "EthernetSpyGlobStatsDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEthernetSpyGlobStatsDlg dialog
CEthernetSpyGlobStatsDlg::CEthernetSpyGlobStatsDlg(EthernetSpyReader* _SpyReader, CWnd* pParent /*=NULL*/)
: CDialog(CEthernetSpyGlobStatsDlg::IDD, pParent)
{
SpyReader = _SpyReader;
uiTimer = 0;
MyParent = pParent;
//{{AFX_DATA_INIT(CEthernetSpyGlobStatsDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CEthernetSpyGlobStatsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEthernetSpyGlobStatsDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEthernetSpyGlobStatsDlg, CDialog)
//{{AFX_MSG_MAP(CEthernetSpyGlobStatsDlg)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_START, OnStart)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_RESET, OnReset)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEthernetSpyGlobStatsDlg message handlers
BOOL CEthernetSpyGlobStatsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
uiTimer = SetTimer(2, SpyReader->RefreshTime, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEthernetSpyGlobStatsDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
TCHAR buffer[255];
unsigned long Total, Broadcast, Multicast, StoredPkt;
double AvgThroughPut, AvgPktLen, AvgPktPerSec;
CDialog::OnTimer(nIDEvent);
EnterCriticalSection(&(SpyReader->CritSecCounters));
{
Total = SpyReader->Stats.Total;
Broadcast = SpyReader->Stats.Broadcast;
Multicast = SpyReader->Stats.Multicast;
AvgThroughPut = SpyReader->Stats.AvgThroughPut;
AvgPktLen = SpyReader->Stats.AvgPktLen;
AvgPktPerSec = SpyReader->Stats.AvgPktPerSec;
StoredPkt = SpyReader->StoredPkt;
}
LeaveCriticalSection(&(SpyReader->CritSecCounters));
wsprintf(buffer, TEXT("%lu"), Total);
SetDlgItemText(IDC_TOTAL, buffer);
wsprintf(buffer, TEXT("%lu"), Broadcast);
SetDlgItemText(IDC_BROAD, buffer);
wsprintf(buffer, TEXT("%lu"), Multicast);
SetDlgItemText(IDC_MULTI, buffer);
wsprintf(buffer, TEXT("%lu"), StoredPkt);
SetDlgItemText(IDC_STORED, buffer);
sprintf(buffer, TEXT("%.2f"), AvgThroughPut);
SetDlgItemText(IDC_THROUGH, buffer);
sprintf(buffer, TEXT("%.2f"), AvgPktPerSec);
SetDlgItemText(IDC_PACK, buffer);
sprintf(buffer, TEXT("%.2f"), AvgPktLen);
SetDlgItemText(IDC_LENGTH, buffer);
}
void CEthernetSpyGlobStatsDlg::OnStart()
{
// TODO: Add your control notification handler code here
if( uiTimer == 0 )
{
uiTimer = SetTimer(1, SpyReader->RefreshTime, NULL);
GetDlgItem(IDC_START)->EnableWindow(FALSE);
GetDlgItem(IDC_STOP)->EnableWindow(TRUE);
}
else
{
return;
}
}
void CEthernetSpyGlobStatsDlg::OnStop()
{
// TODO: Add your control notification handler code here
if( uiTimer == 0 )
{
return;
}
else
{
KillTimer(uiTimer);
uiTimer = 0;
GetDlgItem(IDC_START)->EnableWindow(TRUE);
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
}
}
void CEthernetSpyGlobStatsDlg::OnReset()
{
SpyReader->ClearGlobalStats();
}
void CEthernetSpyGlobStatsDlg::OnClose()
{
MyParent->SendMessage( WM_GLOBSTATSDLGCLOSE );
CDialog::OnClose();
KillTimer(uiTimer);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -