|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: StatisticDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of StatisticDlg.cpp
//----------------------------------------------------------------------------
// StatisticDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "StatisticDlg.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;#endif
/////////////////////////////////////////////////////////////////////////////
// CStatisticDlg dialog
CStatisticDlg::CStatisticDlg(CWnd* pParent /*=NULL*/) : CDialog(CStatisticDlg::IDD, pParent){ //{{AFX_DATA_INIT(CStatisticDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pSensorArray = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CStatisticDlg::CStatisticDlg") );}
void CStatisticDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CStatisticDlg)
DDX_Control(pDX, IDC_EDIT_USER, m_Win9XUser); DDX_Control(pDX, IDC_EDIT_SYSTEM, m_Win9XSystem); DDX_Control(pDX, IDC_EDIT_GDI, m_Win9XGDI); DDX_Control(pDX, IDC_EDIT_VIRTUAL, m_Virtual); DDX_Control(pDX, IDC_EDIT_PHYSICAL, m_Physical); DDX_Control(pDX, IDC_EDIT_PAGEFILE, m_PageFile); DDX_Control(pDX, IDC_LIST_SOCKETS, m_Sockets); //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStatisticDlg, CDialog) //{{AFX_MSG_MAP(CStatisticDlg)
ON_WM_TIMER() //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStatisticDlg message handlers
void CStatisticDlg::SetSensorArray(CSensorArray *pSensorArray){ m_pSensorArray = pSensorArray;}
void CStatisticDlg::OnTimer(UINT nIDEvent) { if( m_pSensorArray ) { for( int i = 0; i < m_pSensorArray->GetSocketCount(); i++ ) { CString str; str.Format( "%d", m_pSensorArray->GetSocket(i)->GetPerformance() ); m_Sockets.SetItemText( i, 1, str );
__int64 s = m_pSensorArray->GetSocket(i)->GetSuccess(); __int64 f = m_pSensorArray->GetSocket(i)->GetFailure();
if( !s ) { if( !f ) m_Sockets.SetItemText( i, 2, "0" ); else {// str.Format( "%I64u(100%%)", f );
str.Format( "%I64u", f ); m_Sockets.SetItemText( i, 2, str ); } m_Sockets.SetItemText( i, 3, "0" ); } else { if( !f ) { m_Sockets.SetItemText( i, 2, "0" );// str.Format( "%I64u(100%%)", s );
str.Format( "%I64u", s ); m_Sockets.SetItemText( i, 3, str ); } else {// double p = 100.0 * f / ( s + f );
// str.Format( "%I64u(~%0.1f%%)", f, p );
str.Format( "%I64u", f ); m_Sockets.SetItemText( i, 2, str );// str.Format( "%I64u(~%0.1f%%)", s, 100.0-p );
str.Format( "%I64u", s ); m_Sockets.SetItemText( i, 3, str ); } } } }
CString strParameter; MEMORYSTATUS ms; ::GlobalMemoryStatus( &ms );/*
#define MAKE_PRETTY_BYTES( s, n ) \
if( n > 1024 * 1024 ) \ s.Format( _T("%dMb"), n >> 20 ); \ else if( n > 1024 ) \ s.Format( _T("%dKb"), n >> 10 ); \ else \ s.Format( _T("%d"), n );
MAKE_PRETTY_BYTES( strParameter, ms.dwAvailPhys ); m_Physical.SetWindowText( strParameter );
MAKE_PRETTY_BYTES( strParameter, ms.dwAvailPageFile ); m_PageFile.SetWindowText( strParameter );
MAKE_PRETTY_BYTES( strParameter, ms.dwAvailVirtual ); m_Virtual.SetWindowText( strParameter );*/ strParameter.Format( _T("%d"), ms.dwAvailPhys ); m_Physical.SetWindowText( strParameter );
strParameter.Format( _T("%d"), ms.dwAvailPageFile ); m_PageFile.SetWindowText( strParameter );
strParameter.Format( _T("%d"), ms.dwAvailVirtual ); m_Virtual.SetWindowText( strParameter );
strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetSystemResources() ); m_Win9XSystem.SetWindowText( strParameter );
strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetUserResources() ); m_Win9XUser.SetWindowText( strParameter );
strParameter.Format( _T("%d%%"), m_ResourceMeterWin9x.GetGDIResources() ); m_Win9XGDI.SetWindowText( strParameter );
CDialog::OnTimer(nIDEvent);}
BOOL CStatisticDlg::OnInitDialog() { CDialog::OnInitDialog();
CRect rect; m_Sockets.GetClientRect( &rect ); int nWidth = rect.Width() / 4;
m_Sockets.InsertColumn( 0, "Line", LVCFMT_LEFT, nWidth, 0 ); m_Sockets.InsertColumn( 1, "Speed", LVCFMT_LEFT, nWidth, 1 ); m_Sockets.InsertColumn( 2, "Failure", LVCFMT_LEFT, nWidth, 2 ); m_Sockets.InsertColumn( 3, "Success", LVCFMT_LEFT, nWidth, 3 );
if( m_pSensorArray ) { for( int i = 0; i < m_pSensorArray->GetSocketCount(); i++ ) { CString str = m_pSensorArray->GetSocket( i )->GetName(); m_Sockets.InsertItem( i, str ); } } m_ResourceMeterWin9x.Create();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
|