📄 statistics.cpp
字号:
/*************************************************
Copyright (C), 2000-2002, Huayue Co., Ltd.
File name: Statistics.cpp
Module: NMS统计信息
Author: 王华东
Version: 1.0
Created on : 2003.01
Description: 主模块、主线程
Global function List:
Modify History:
Date: Author: Modification:
2003
1. 03.22 WHD 改为属性页方式显示统计信息v205
*************************************************/
#include "stdafx.h"
#include "..\nms.h"
#include "Statistics.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CBrush *g_pWhiteBrush; /* 背景颜色 */
/////////////////////////////////////////////////////////////////////////////
// CStatistics dialog
CStatistics::CStatistics(CWnd* pParent /*=NULL*/)
: CDialog(CStatistics::IDD, pParent)
{
//{{AFX_DATA_INIT(CStatistics)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CStatistics::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStatistics)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
//ON_BN_CLICKED(IDC_STAT_RESET, OnReset)
BEGIN_MESSAGE_MAP(CStatistics, CDialog)
//{{AFX_MSG_MAP(CStatistics)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_STATISTICS_OK, OnStatisticsOk)
ON_BN_CLICKED(IDC_STATISTICS_RESET, OnStatisticsReset)
ON_BN_CLICKED(IDC_STATISTICS_TAB , OnTabClick)
ON_BN_CLICKED(IDC_STATISTICS_REFRESH, OnStatisticsRefresh)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStatistics message handlers
/*-----------------------------------------------------------------*/
BOOL CStatistics::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect , rcDlg;
GetClientRect(&rect);
// if add TCS_TABS|TCS_BUTTONS then will no XP style (in winxp)
if(m_TabCtrl.Create(/*TCS_TABS|TCS_BUTTONS|*/WS_VISIBLE|WS_CHILD|WS_TABSTOP , CRect(10 , 0 , rect.Width() , 25) , this , IDC_STATISTICS_TAB) == FALSE)
{
return FALSE;
}
m_TabCtrl.InsertItem(0 , "告警");
m_TabCtrl.InsertItem(1 , "性能");
m_TabCtrl.InsertItem(2 , "数据库命令");
m_AlarmPage.Create(IDD_ALARM_STATISTICS , this);
m_PerfPage.Create(IDD_PERF_STATISTICS , this);
m_DbPage.Create(IDD_DB_STATISTICS , this);
m_TabCtrl.SetCurSel(0);
m_TabCtrl.GetClientRect(&rect);
m_AlarmPage.ShowWindow(SW_SHOW);
m_AlarmPage.GetClientRect(&rcDlg);
m_AlarmPage.MoveWindow(10 , rect.Height() , rcDlg.Width() , rcDlg.Height());
m_DbPage.ShowWindow(SW_HIDE);
m_PerfPage.ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/*-----------------------------------------------------------------*/
HBRUSH CStatistics::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)g_pWhiteBrush->m_hObject;
// TODO: Return a different brush if the default is not desired
//return hbr;
}
/*-----------------------------------------------------------------*/
// 切换视图
void CStatistics::OnTabClick()
{
int iSel = m_TabCtrl.GetCurSel();
CRect rect , rcDlg;
m_TabCtrl.GetClientRect(&rect);
switch(iSel)
{
case 0:
m_AlarmPage.ShowWindow(SW_SHOW);
m_AlarmPage.GetClientRect(&rcDlg);
m_AlarmPage.MoveWindow(10 , rect.Height() , rcDlg.Width() , rcDlg.Height());
m_DbPage.ShowWindow(SW_HIDE);
m_PerfPage.ShowWindow(SW_HIDE);
break;
case 1:
m_PerfPage.ShowWindow(SW_SHOW);
m_PerfPage.GetClientRect(&rcDlg);
m_PerfPage.MoveWindow(10 , rect.Height() , rcDlg.Width() , rcDlg.Height());
m_DbPage.ShowWindow(SW_HIDE);
m_AlarmPage.ShowWindow(SW_HIDE);
break;
case 2:
m_DbPage.ShowWindow(SW_SHOW);
m_DbPage.GetClientRect(&rcDlg);
m_DbPage.MoveWindow(10 , rect.Height() , rcDlg.Width() , rcDlg.Height());
m_PerfPage.ShowWindow(SW_HIDE);
m_AlarmPage.ShowWindow(SW_HIDE);
break;
}
}
/*-----------------------------------------------------------------*/
// 退出
void CStatistics::OnStatisticsOk()
{
CDialog::OnOK();
}
/*-----------------------------------------------------------------*/
// 复位
void CStatistics::OnStatisticsReset()
{
int iSel = m_TabCtrl.GetCurSel();
if(iSel == 0)
{
m_AlarmPage.OnAlarmStaReset();
}
else if(iSel == 1)
{
m_PerfPage.OnPerfStaReset();
}
else
{
m_DbPage.OnDbStaReset();
}
}
/*-----------------------------------------------------------------*/
// 更新
void CStatistics::OnStatisticsRefresh()
{
int iSel = m_TabCtrl.GetCurSel();
if(iSel == 0)
{
m_AlarmPage.OnAlarmStaRefresh();
}
else if(iSel == 1)
{
m_PerfPage.OnPerfStaRefresh();
}
else
{
m_DbPage.OnDbStaRefresh();
}
}
/*-----------------------------------------------------------------*/
//
LRESULT CStatistics::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// 截获TabCtrl发出的消息
if(message == WM_NOTIFY)
{
NMHDR *pNMHDR = (NMHDR*)lParam;
if( (pNMHDR->idFrom == IDC_STATISTICS_TAB) &&
(pNMHDR->code == NM_CLICK)
)
{
OnTabClick();
return TRUE;
}
}
return CDialog::WindowProc(message, wParam, lParam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -