From 08b5c2fbea7167f0574388856223c371ef91948f Mon Sep 17 00:00:00 2001 From: Zhong Yang Date: Tue, 8 May 2018 11:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=BA=9B=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=97=B6=E7=9A=84=E8=AD=A6=E5=91=8A=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E6=96=B9=E9=9D=A2=E7=9A=84=E6=94=B9=E8=BF=9B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TrafficMonitor/HistoryTrafficListDlg.cpp | Bin 10828 -> 10834 bytes TrafficMonitor/ListCtrlEx.cpp | 2 +- TrafficMonitor/NetworkInfoDlg.cpp | 2 +- TrafficMonitor/TrafficMonitor.rc | Bin 123966 -> 123992 bytes TrafficMonitor/TrafficMonitor.vcxproj | 1 + TrafficMonitor/TrafficMonitorDlg.cpp | 17 ++++++++++++----- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/TrafficMonitor/HistoryTrafficListDlg.cpp b/TrafficMonitor/HistoryTrafficListDlg.cpp index 4cefd91b6f66c8a294a42ac3585583464907c348..fa4459e11678a379fd17dbda929864a9bc70d311 100644 GIT binary patch delta 22 ecmX>Taw%lPBq7dXhD?SkhE#_5%~OT8ivs{-$p_{D delta 16 YcmcZ?W06t#^qW}N^ diff --git a/TrafficMonitor/ListCtrlEx.cpp b/TrafficMonitor/ListCtrlEx.cpp index b7926a3f0..8fee83d00 100644 --- a/TrafficMonitor/ListCtrlEx.cpp +++ b/TrafficMonitor/ListCtrlEx.cpp @@ -14,7 +14,7 @@ CListCtrlEx::~CListCtrlEx() void CListCtrlEx::SetDrawItemRangeData(int item, double range, COLORREF color) { if (item < 0) return; - if (item >= m_item_rage_data.size()) + if (item >= static_cast(m_item_rage_data.size())) m_item_rage_data.resize(item + 1); m_item_rage_data[item].data_value = range; m_item_rage_data[item].color = color; diff --git a/TrafficMonitor/NetworkInfoDlg.cpp b/TrafficMonitor/NetworkInfoDlg.cpp index 08b2b7784..e6506f61f 100644 --- a/TrafficMonitor/NetworkInfoDlg.cpp +++ b/TrafficMonitor/NetworkInfoDlg.cpp @@ -103,7 +103,7 @@ void CNetworkInfoDlg::ShowInfo() m_info_list.InsertItem(4, CCommon::LoadText(IDS_ADAPTER_PHYSICAL_ADDRESS)); temp = _T(""); char buff[3]; - for (int i{}; i < m_network_info.dwPhysAddrLen; i++) + for (size_t i{}; i < m_network_info.dwPhysAddrLen; i++) { //_itoa_s(m_network_info.bPhysAddr[i], buff, 16); sprintf_s(buff, "%.2x", m_network_info.bPhysAddr[i]); diff --git a/TrafficMonitor/TrafficMonitor.rc b/TrafficMonitor/TrafficMonitor.rc index bf91f81fe9f975c0ae7cb6dd0fdfe3eaa3f683eb..6a3f6479a8b181a28f534606ee7d809406f80cae 100644 GIT binary patch delta 309 zcmdmYg8jw`_6>b6nVAffCO0MvPrq=NQEKy^m-lR$4H!%(8@^pS-ARLS7qbO}$z(xA z>*)ffj7rmEG#R-dBB9ok6U2F@Z_s4)U^Jf`7%w|nZ-&NX2UUgbaaxSaWSGqv%qJU~ znNB`nEVez!opA*-voV9|_P<_?nM{n9lNoJArw8~jDs5lj%h;mHlQTGJndGO7q0GME7&MA`sI z8#5SAerQ`h-GPl!Vf&ge#y$yVLk7#q6I*q+XXP_i8BE^sOJ)0y`HW6n!g&n&3?&Q- s45i!_6>b6r!P9kC^DIgS8DUVm-lR$4H?Y0&sS%RXJocyFq_V($(RmeOco5a zo}3`gGkJlI-SiKdj9knX45pJClcgu?&CuBHpv8Dh1}I`a+0e{%@&RM9?IG@rE0~#0 z7)-YR_hQUsVl`wi0IE;4GTpwwm$8G9*_6S2y0$-KE|6h1eYQX2ZIJHig+`2q+gAlJ zzG0bsp@4;^zl69%Kn4{gi0PY7dNC&6k2 zRB13daH971ynMzg1K~u55(Wi^Vj!8wPy{4P849*@FJN@$63=AF1B#b2qyb?jLoyJj d0!2!;C$3_gsMmm*8vvm(S9SmZ diff --git a/TrafficMonitor/TrafficMonitor.vcxproj b/TrafficMonitor/TrafficMonitor.vcxproj index 40ebba013..cf0bf1b5a 100644 --- a/TrafficMonitor/TrafficMonitor.vcxproj +++ b/TrafficMonitor/TrafficMonitor.vcxproj @@ -92,6 +92,7 @@ Disabled WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) true + false Windows diff --git a/TrafficMonitor/TrafficMonitorDlg.cpp b/TrafficMonitor/TrafficMonitorDlg.cpp index 2a5e0004e..ea0d81f55 100644 --- a/TrafficMonitor/TrafficMonitorDlg.cpp +++ b/TrafficMonitor/TrafficMonitorDlg.cpp @@ -578,7 +578,7 @@ void CTrafficMonitorDlg::AutoSelect() //m_connection_selected = m_connections[0].index; m_connection_selected = 0; //自动选择连接时,查找已发送和已接收字节数之和最多的那个连接,并将其设置为当前查看的连接 - for (int i{}; itable[m_connections[i].index].dwOperStatus == IF_OPER_STATUS_OPERATIONAL) //只选择网络状态为正常的连接 { @@ -650,7 +650,7 @@ void CTrafficMonitorDlg::IniConnection() m_menu.LoadMenu(IDR_MENU1); //装载右键菜单 m_select_connection_menu = m_menu.GetSubMenu(0)->GetSubMenu(0); //设置“选择网卡”子菜单项 CString connection_descr; - for (int i{}; i < m_connections.size(); i++) + for (size_t i{}; i < m_connections.size(); i++) { connection_descr = CCommon::StrToUnicode(m_connections[i].description.c_str()).c_str(); m_select_connection_menu->AppendMenu(MF_STRING | MF_ENABLED, ID_SELETE_CONNECTION + i + 1, connection_descr); @@ -767,7 +767,7 @@ void CTrafficMonitorDlg::LoadHistoryTraffic() std::sort(m_history_traffics.begin(), m_history_traffics.end(), HistoryTraffic::DateGreater); //如果列表中有相同日期的项目,则将它合并 - for (int i{}; i < m_history_traffics.size() - 1; i++) + for (int i{}; i < static_cast(m_history_traffics.size() - 1); i++) { if (HistoryTraffic::DateEqual(m_history_traffics[i], m_history_traffics[i + 1])) { @@ -1195,7 +1195,14 @@ void CTrafficMonitorDlg::OnTimer(UINT_PTR nIDEvent) m_history_traffics[0].kBytes = static_cast(theApp.m_today_traffic / 1024); //每隔30秒保存一次流量历史记录 if (m_timer_cnt % 30 == 10) - SaveHistoryTraffic(); + { + static unsigned int last_today_kbytes; + if (m_history_traffics[0].kBytes - last_today_kbytes >= 100) //只有当流量变化超过100KB时才保存历史流量记录,防止磁盘写入过于频繁 + { + SaveHistoryTraffic(); + last_today_kbytes = m_history_traffics[0].kBytes; + } + } if (rtn == ERROR_INSUFFICIENT_BUFFER) { @@ -1316,7 +1323,7 @@ void CTrafficMonitorDlg::OnTimer(UINT_PTR nIDEvent) { static int last_memory_usage; static int notify_time{ -theApp.m_notify_interval }; //记录上次弹出提示时的时间 - if (last_memory_usage < theApp.m_general_data.memory_tip_value && theApp.m_memory_usage >= theApp.m_general_data.memory_tip_value && (m_timer_cnt - notify_time > theApp.m_notify_interval)) + if (last_memory_usage < theApp.m_general_data.memory_tip_value && theApp.m_memory_usage >= theApp.m_general_data.memory_tip_value && (m_timer_cnt - notify_time > static_cast(theApp.m_notify_interval))) { CString info; info.Format(CCommon::LoadText(IDS_MEMORY_UDAGE_EXCEED, _T(" %d%%!")), theApp.m_general_data.memory_tip_value);