diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 8430625..0000000 --- a/src/README.md +++ /dev/null @@ -1,106 +0,0 @@ - -##### 说明 - -硬盘上的一份截图代码,作者是[sudami](https://bbs.pediy.com/thread-54302.htm)。 - -提取了里面的3个类CatchScreenDlg、MyTracker.h,MyEdit,自己在实现下。 - -双缓冲,完美无闪烁。 - -##### 截图 - -![snatshot.png](snatshot.png) - - -##### 说明 - -1、重写了MyEdit的绘制,避免闪烁。 - -2、修改CCatchScreenDlg中部分逻辑,避免闪烁 - -3、增加ToolBar控件,仿QQ截图界面。按钮实际功能未开发。 - -4、实现截图飞选中区域暗色处理 - - -##### ToolBar控件消息处理 - -```c++ -BOOL CCatchScreenDlg::OnCommand(WPARAM wParam, LPARAM lParam) -{ - bool bHandle = true; - HWND hWnd = m_toolBar.GetHWND(); - if(lParam == (LPARAM)m_toolBar.GetHWND()) - { - int wmId = LOWORD(wParam); - switch(wmId) - { - case MyToolBar_ID: - AfxMessageBox(_T("矩形")); - break; - case MyToolBar_ID+1: - AfxMessageBox(_T("圆形")); - break; - case MyToolBar_ID +2: - AfxMessageBox(_T("画笔")); - break; - case MyToolBar_ID +3: - AfxMessageBox(_T("马赛克")); - break; - case MyToolBar_ID +4: - AfxMessageBox(_T("文字")); - break; - case MyToolBar_ID +5: - AfxMessageBox(_T("撤销")); - break; - case MyToolBar_ID +6: - CopyScreenToBitmap(m_rectTracker.m_rect, TRUE); - PostQuitMessage(0); - break; - case MyToolBar_ID +7: - PostQuitMessage(0); - break; - case MyToolBar_ID +8: - CopyScreenToBitmap(m_rectTracker.m_rect, TRUE); - PostQuitMessage(0); - break; - default: - bHandle = false; - break; - } - ::SetFocus(hWnd); - } - if (bHandle == false) - { - return CDialog::OnCommand(wParam,lParam); - } -} -``` - - -##### 神奇的非选中区域暗色处理算法 - -```c++ - Gdiplus::Graphics graphics(dcCompatible); - - HRGN hgn1 = CreateRectRgn(m_rectTracker.m_rect.left,m_rectTracker.m_rect.top, - m_rectTracker.m_rect.right,m_rectTracker.m_rect.bottom); - Region region1(hgn1); - - HRGN hgn2 = CreateRectRgn(rect.left,rect.top, - rect.right,rect.bottom); - Region region2(hgn2); - - region2.Exclude(®ion1); - - SolidBrush solidBrush(Color(100, 128, 128, 128)); - graphics.FillRegion(&solidBrush,®ion2); - - DeleteObject(hgn1); - DeleteObject(hgn2); -``` - - - - - diff --git a/src/Release/Screenshot.exe b/src/Release/Screenshot.exe deleted file mode 100644 index 771fb85..0000000 Binary files a/src/Release/Screenshot.exe and /dev/null differ diff --git a/src/Screenshot.sln b/src/Screenshot.sln deleted file mode 100644 index 732cc79..0000000 --- a/src/Screenshot.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Screenshot", "Screenshot\Screenshot.vcproj", "{24E39ACB-AB81-485D-8D36-749B3F5EC1E8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {24E39ACB-AB81-485D-8D36-749B3F5EC1E8}.Debug|Win32.ActiveCfg = Debug|Win32 - {24E39ACB-AB81-485D-8D36-749B3F5EC1E8}.Debug|Win32.Build.0 = Debug|Win32 - {24E39ACB-AB81-485D-8D36-749B3F5EC1E8}.Release|Win32.ActiveCfg = Release|Win32 - {24E39ACB-AB81-485D-8D36-749B3F5EC1E8}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/TrafficMonitor/.vs/TrafficMonitor/v14/.suo b/src/TrafficMonitor/.vs/TrafficMonitor/v14/.suo new file mode 100644 index 0000000..243f435 Binary files /dev/null and b/src/TrafficMonitor/.vs/TrafficMonitor/v14/.suo differ diff --git a/src/TrafficMonitor/.vs/TrafficMonitor/v15/.suo b/src/TrafficMonitor/.vs/TrafficMonitor/v15/.suo new file mode 100644 index 0000000..5e08777 Binary files /dev/null and b/src/TrafficMonitor/.vs/TrafficMonitor/v15/.suo differ diff --git a/src/TrafficMonitor/.vs/TrafficMonitor/v15/Browse.VC.db b/src/TrafficMonitor/.vs/TrafficMonitor/v15/Browse.VC.db new file mode 100644 index 0000000..df3eea1 Binary files /dev/null and b/src/TrafficMonitor/.vs/TrafficMonitor/v15/Browse.VC.db differ diff --git a/src/TrafficMonitor/.vs/TrafficMonitor/v15/ipch/827231db548299d3.ipch b/src/TrafficMonitor/.vs/TrafficMonitor/v15/ipch/827231db548299d3.ipch new file mode 100644 index 0000000..2912183 Binary files /dev/null and b/src/TrafficMonitor/.vs/TrafficMonitor/v15/ipch/827231db548299d3.ipch differ diff --git a/src/TrafficMonitor/Release/TrafficMonitor.exe b/src/TrafficMonitor/Release/TrafficMonitor.exe new file mode 100644 index 0000000..4f4f1fa Binary files /dev/null and b/src/TrafficMonitor/Release/TrafficMonitor.exe differ diff --git a/src/TrafficMonitor/Release/config.ini b/src/TrafficMonitor/Release/config.ini new file mode 100644 index 0000000..2349a8b --- /dev/null +++ b/src/TrafficMonitor/Release/config.ini @@ -0,0 +1,35 @@ +[config] +transparency=100 +always_on_top=0 +lock_window_pos=0 +show_notify_icon=1 +show_cpu_memory=1 +mouse_penetrate=0 +show_task_bar_wnd=1 +position_x=1420 +position_y=900 +text_color=14547455 +hide_main_window=0 +skin_selected=\Ƥ07 +font_name=΢ź +font_size=10 +swap_up_down=0 +hide_main_wnd_when_fullscreen=1 +up_string=ϴ: $ +down_string=: $ +cpu_string=CPU: $ +memory_string=ڴ: $ +[connection] +auto_select=1 +connection_name=Intel(R) Wi-Fi 6 AX200 160MHz-WFP Native MAC Layer LightWeight Filter-0000 +[task_bar] +task_bar_back_color=0 +task_bar_text_color=16777215 +tack_bar_show_cpu_memory=1 +tack_bar_font_name=΢ź +tack_bar_font_size=9 +task_bar_swap_up_down=0 +up_string=: $ +down_string=: $ +cpu_string=CPU: $ +memory_string=ڴ: $ diff --git a/src/TrafficMonitor/Release/desktop.ini b/src/TrafficMonitor/Release/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/src/TrafficMonitor/Release/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/src/TrafficMonitor/Release/history_traffic.dat b/src/TrafficMonitor/Release/history_traffic.dat new file mode 100644 index 0000000..f3d9bf5 --- /dev/null +++ b/src/TrafficMonitor/Release/history_traffic.dat @@ -0,0 +1,9 @@ +2023/11/06 5 +2017/11/16 35534 +2017/11/15 105882 +2017/11/14 152433 +2017/10/23 11649 +2017/07/28 7405 +2017/07/05 47 +2017/07/04 984 +2017/06/25 133 diff --git a/src/TrafficMonitor/Release/skins/0默认皮肤/background.bmp b/src/TrafficMonitor/Release/skins/0默认皮肤/background.bmp new file mode 100644 index 0000000..11980c5 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/0默认皮肤/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/0默认皮肤/background_l.bmp b/src/TrafficMonitor/Release/skins/0默认皮肤/background_l.bmp new file mode 100644 index 0000000..6b6fed3 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/0默认皮肤/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/0默认皮肤/skin.ini b/src/TrafficMonitor/Release/skins/0默认皮肤/skin.ini new file mode 100644 index 0000000..8036f92 --- /dev/null +++ b/src/TrafficMonitor/Release/skins/0默认皮肤/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=16384 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤01/background.bmp b/src/TrafficMonitor/Release/skins/皮肤01/background.bmp new file mode 100644 index 0000000..93885c8 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤01/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤01/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤01/background_l.bmp new file mode 100644 index 0000000..e653b8e Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤01/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤01/skin.ini b/src/TrafficMonitor/Release/skins/皮肤01/skin.ini new file mode 100644 index 0000000..03c08ed --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤01/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=3803808 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤02/background.bmp b/src/TrafficMonitor/Release/skins/皮肤02/background.bmp new file mode 100644 index 0000000..c287347 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤02/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤02/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤02/background_l.bmp new file mode 100644 index 0000000..401b788 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤02/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤02/skin.ini b/src/TrafficMonitor/Release/skins/皮肤02/skin.ini new file mode 100644 index 0000000..7aa1311 --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤02/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=9844741 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤03/background.bmp b/src/TrafficMonitor/Release/skins/皮肤03/background.bmp new file mode 100644 index 0000000..cc77607 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤03/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤03/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤03/background_l.bmp new file mode 100644 index 0000000..2c8635c Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤03/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤03/skin.ini b/src/TrafficMonitor/Release/skins/皮肤03/skin.ini new file mode 100644 index 0000000..76342fe --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤03/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=16777215 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤04/background.bmp b/src/TrafficMonitor/Release/skins/皮肤04/background.bmp new file mode 100644 index 0000000..22c5507 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤04/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤04/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤04/background_l.bmp new file mode 100644 index 0000000..84629bb Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤04/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤04/skin.ini b/src/TrafficMonitor/Release/skins/皮肤04/skin.ini new file mode 100644 index 0000000..76342fe --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤04/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=16777215 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤05/background.bmp b/src/TrafficMonitor/Release/skins/皮肤05/background.bmp new file mode 100644 index 0000000..5cff16d Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤05/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤05/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤05/background_l.bmp new file mode 100644 index 0000000..0261bfb Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤05/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤05/skin.ini b/src/TrafficMonitor/Release/skins/皮肤05/skin.ini new file mode 100644 index 0000000..c9b52bf --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤05/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=335674 +skin_author=zy_ \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤06/background.bmp b/src/TrafficMonitor/Release/skins/皮肤06/background.bmp new file mode 100644 index 0000000..f578d74 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤06/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤06/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤06/background_l.bmp new file mode 100644 index 0000000..0f1b0f2 Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤06/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤06/skin.ini b/src/TrafficMonitor/Release/skins/皮肤06/skin.ini new file mode 100644 index 0000000..67a866e --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤06/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=16773870 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/Release/skins/皮肤07/background.bmp b/src/TrafficMonitor/Release/skins/皮肤07/background.bmp new file mode 100644 index 0000000..23e940d Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤07/background.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤07/background_l.bmp b/src/TrafficMonitor/Release/skins/皮肤07/background_l.bmp new file mode 100644 index 0000000..63ce91d Binary files /dev/null and b/src/TrafficMonitor/Release/skins/皮肤07/background_l.bmp differ diff --git a/src/TrafficMonitor/Release/skins/皮肤07/skin.ini b/src/TrafficMonitor/Release/skins/皮肤07/skin.ini new file mode 100644 index 0000000..7b3375f --- /dev/null +++ b/src/TrafficMonitor/Release/skins/皮肤07/skin.ini @@ -0,0 +1,3 @@ +[skin] +text_color=14547455 +skin_author=zy \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor.sln b/src/TrafficMonitor/TrafficMonitor.sln new file mode 100644 index 0000000..48d3a0e --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrafficMonitor", "TrafficMonitor\TrafficMonitor.vcxproj", "{09483BED-B1E9-4827-8120-A18302C84AA8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09483BED-B1E9-4827-8120-A18302C84AA8}.Debug|x64.ActiveCfg = Debug|x64 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Debug|x64.Build.0 = Debug|x64 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Debug|x86.ActiveCfg = Debug|Win32 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Debug|x86.Build.0 = Debug|Win32 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Release|x64.ActiveCfg = Release|x64 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Release|x64.Build.0 = Release|x64 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Release|x86.ActiveCfg = Release|Win32 + {09483BED-B1E9-4827-8120-A18302C84AA8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/TrafficMonitor/TrafficMonitor/Common.cpp b/src/TrafficMonitor/TrafficMonitor/Common.cpp new file mode 100644 index 0000000..88c3597 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/Common.cpp @@ -0,0 +1,334 @@ +#include "stdafx.h" +#include "Common.h" + + +CCommon::CCommon() +{ +} + + +CCommon::~CCommon() +{ +} + +wstring CCommon::StrToUnicode(const char* str) +{ + wstring result; + int size; + size = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + if (size <= 0) return wstring(); + wchar_t* str_unicode = new wchar_t[size + 1]; + MultiByteToWideChar(CP_ACP, 0, str, -1, str_unicode, size); + result.assign(str_unicode); + delete[] str_unicode; + return result; +} + +string CCommon::UnicodeToStr(const wchar_t * wstr) +{ + string result; + int size{ 0 }; + size = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL); + if (size <= 0) return string(); + char* str = new char[size + 1]; + WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, size, NULL, NULL); + result.assign(str); + delete[] str; + return result; +} + +bool CCommon::WritePrivateProfileIntW(const wchar_t * AppName, const wchar_t * KeyName, int value, const wchar_t * Path) +{ + wchar_t buff[11]; + _itow_s(value, buff, 10); + return (WritePrivateProfileStringW(AppName, KeyName, buff, Path) != FALSE); +} + +CString CCommon::DataSizeToString(unsigned int size) +{ + CString str; + if (size < 1024 * 10) //10KBKBΪλ2λС + str.Format(_T("%.2fKB"), size / 1024.0f); + else if (size < 1024 * 1024) //1MBKBΪλ1λС + str.Format(_T("%.1fKB"), size / 1024.0f); + else if (size < 1024 * 1024 * 1024) //1GBMBΪλ2λС + str.Format(_T("%.2fMB"), size / 1024.0f / 1024.0f); + else + str.Format(_T("%.2fGB"), size / 1024.0f / 1024.0f / 1024.0f); + return str; +} + +CString CCommon::KBytesToString(unsigned int kb_size) +{ + CString k_bytes_str; + if (kb_size < 1024) + k_bytes_str.Format(_T("%dKB"), kb_size); + else if (kb_size < 1024 * 1024) + k_bytes_str.Format(_T("%.2fMB"), kb_size / 1024.0); + else + k_bytes_str.Format(_T("%.2fGB"), kb_size / 1024.0 / 1024.0); + return k_bytes_str; +} + +__int64 CCommon::CompareFileTime2(FILETIME time1, FILETIME time2) +{ + __int64 a = static_cast<__int64>(time1.dwHighDateTime) << 32 | time1.dwLowDateTime; + __int64 b = static_cast<__int64>(time2.dwHighDateTime) << 32 | time2.dwLowDateTime; + return b - a; +} + +void CCommon::WriteLog(const char* str_text, LPCTSTR file_path) +{ + SYSTEMTIME cur_time; + GetLocalTime(&cur_time); + char buff[32]; + sprintf_s(buff, "%d/%.2d/%.2d %.2d:%.2d:%.2d.%.3d: ", cur_time.wYear, cur_time.wMonth, cur_time.wDay, + cur_time.wHour, cur_time.wMinute, cur_time.wSecond, cur_time.wMilliseconds); + ofstream file{ file_path, std::ios::app }; //׷ӵķʽ־ļ + file << buff; + file << str_text << std::endl; +} + +BOOL CCommon::CreateFileShortcut(LPCTSTR lpszLnkFileDir, LPCTSTR lpszFileName, LPCTSTR lpszLnkFileName, LPCTSTR lpszWorkDir, WORD wHotkey, LPCTSTR lpszDescription, int iShowCmd) +{ + if (lpszLnkFileDir == NULL) + return FALSE; + + HRESULT hr; + IShellLink *pLink; //IShellLinkָ + IPersistFile *ppf; //IPersisFilָ + + //IShellLink + hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pLink); + if (FAILED(hr)) + return FALSE; + + //IShellLinkлȡIPersistFileӿ + hr = pLink->QueryInterface(IID_IPersistFile, (void**)&ppf); + if (FAILED(hr)) + { + pLink->Release(); + return FALSE; + } + + TCHAR file_path[MAX_PATH]; + GetModuleFileName(NULL, file_path, MAX_PATH); + + //Ŀ + if (lpszFileName == NULL) + pLink->SetPath(file_path); + else + pLink->SetPath(lpszFileName); + + //Ŀ¼ + if (lpszWorkDir != NULL) + { + pLink->SetWorkingDirectory(lpszWorkDir); + } + else + { + //ùĿ¼ΪݷʽĿλ + TCHAR workDirBuf[MAX_PATH]; + if (lpszFileName == NULL) + wcscpy_s(workDirBuf, file_path); + else + wcscpy_s(workDirBuf, lpszFileName); + LPTSTR pstr = wcsrchr(workDirBuf, _T('\\')); + *pstr = _T('\0'); + pLink->SetWorkingDirectory(workDirBuf); + } + + //ݼ + if (wHotkey != 0) + pLink->SetHotkey(wHotkey); + + //ע + if (lpszDescription != NULL) + pLink->SetDescription(lpszDescription); + + //ʾʽ + pLink->SetShowCmd(iShowCmd); + + + //ݷʽ· + + wchar_t szBuffer[MAX_PATH]; + if (lpszLnkFileName != NULL) //ָ˿ݷʽ + swprintf_s(szBuffer, L"%s\\%s", lpszLnkFileDir, lpszLnkFileName); + else + { + //ûָƣʹȡָļļΪݷʽơ + const wchar_t *pstr; + if (lpszFileName != NULL) + pstr = wcsrchr(lpszFileName, L'\\'); + else + pstr = wcsrchr(file_path, L'\\'); + + if (pstr == NULL) + { + ppf->Release(); + pLink->Release(); + return FALSE; + } + //ע׺Ҫ.exeΪ.lnk + swprintf_s(szBuffer, L"%s\\%s", lpszLnkFileDir, pstr); + int nLen = wcslen(szBuffer); + szBuffer[nLen - 3] = L'l'; + szBuffer[nLen - 2] = L'n'; + szBuffer[nLen - 1] = L'k'; + } + //ݷʽָĿ¼ + //WCHAR wsz[MAX_PATH]; //Unicodeַ + //MultiByteToWideChar(CP_ACP, 0, szBuffer, -1, wsz, MAX_PATH); + + hr = ppf->Save(szBuffer, TRUE); + + ppf->Release(); + pLink->Release(); + return SUCCEEDED(hr); +} + +wstring CCommon::GetStartUpPath() +{ + LPITEMIDLIST ppidl; + TCHAR pszStartUpPath[MAX_PATH]; + if (SHGetSpecialFolderLocation(NULL, CSIDL_STARTUP, &ppidl) == S_OK) + { + SHGetPathFromIDList(ppidl, pszStartUpPath); + CoTaskMemFree(ppidl); + } + return wstring(pszStartUpPath); +} + +void CCommon::GetFiles(const wchar_t* path, vector& files) +{ + //ļ + int hFile = 0; + //ļϢUnicodeʹ_wfinddata_tַֽʹ_finddata_t + _wfinddata_t fileinfo; + wstring file_name; + if ((hFile = _wfindfirst(wstring(path).append(L"\\*").c_str(), &fileinfo)) != -1) + { + do + { + file_name.assign(fileinfo.name); + if (file_name != L"." && file_name != L"..") + //files.push_back(wstring(path) + L"\\" + file_name); //ļ(".""..") + files.push_back(L"\\" + file_name); //ļ(".""..") + } while (_wfindnext(hFile, &fileinfo) == 0); + } + _findclose(hFile); +} + +bool CCommon::FileExist(LPCTSTR file_name) +{ + _wfinddata_t fileinfo; + return (_wfindfirst(file_name, &fileinfo) != -1); +} + +SYSTEMTIME CCommon::CompareSystemTime(SYSTEMTIME a, SYSTEMTIME b) +{ + SYSTEMTIME result{}; + short hour = a.wHour - b.wHour; + short minute = a.wMinute - b.wMinute; + short second = a.wSecond - b.wSecond; + + if (second < 0) + { + second += 60; + minute--; + } + + if (minute < 0) + { + minute += 60; + hour--; + } + + if (hour < 0) + { + hour += 24; + } + result.wHour = hour; + result.wMinute = minute; + result.wSecond = second; + return result; +} + +wstring CCommon::GetExePath() +{ + wchar_t path[MAX_PATH]; + GetModuleFileNameW(NULL, path, MAX_PATH); + size_t index; + wstring current_path{ path }; + index = current_path.find_last_of(L'\\'); + current_path = current_path.substr(0, index + 1); + return current_path; +} + +void CCommon::DrawWindowText(CDC * pDC, CRect rect, LPCTSTR lpszString, COLORREF color, COLORREF back_color) +{ + pDC->SetTextColor(color); + //m_pDC->SetBkMode(TRANSPARENT); + //ñɫ + pDC->FillSolidRect(rect, back_color); + pDC->DrawText(lpszString, rect, DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); + +} + +void CCommon::FillStaticColor(CStatic & static_ctr, COLORREF color) +{ + CDC* pDC = static_ctr.GetDC(); + CRect rect; + static_ctr.GetClientRect(&rect); + pDC->FillSolidRect(rect, color); +} + + +bool CCommon::IsForegroundFullscreen() +{ + bool bFullscreen{ false }; //ָʾǰ̨Ƿȫ + HWND hWnd; + RECT rcApp; + RECT rcDesk; + hWnd = GetForegroundWindow(); //ȡǰûǰ̨ھ + TCHAR buff[256]; + GetClassName(hWnd, buff, 256); //ȡǰ̨ڵ + CString class_name{ buff }; + if (hWnd != GetDesktopWindow() && class_name!=_T("WorkerW") && hWnd != GetShellWindow())//ǰ̨ڲ洰ڣҲǿ̨ + { + GetWindowRect(hWnd, &rcApp); //ȡǰ̨ڵ + GetWindowRect(GetDesktopWindow(), &rcDesk); //洰ھȡĻ + if (rcApp.left <= rcDesk.left && //ǰ̨ڵȫס洰ڣͱʾǰ̨ȫ + rcApp.top <= rcDesk.top && + rcApp.right >= rcDesk.right && + rcApp.bottom >= rcDesk.bottom) + { + bFullscreen = true; + } + }//ǰ̨洰ڣǿ̨ڣֱӷزȫ + return bFullscreen; +} + +bool CCommon::CopyStringToClipboard(const wstring & str) +{ + if (OpenClipboard(NULL)) + { + HGLOBAL clipbuffer; + EmptyClipboard(); + size_t size = (str.size() + 1) * 2; + clipbuffer = GlobalAlloc(GMEM_DDESHARE, size); + memcpy_s(GlobalLock(clipbuffer), size, str.c_str(), size); + GlobalUnlock(clipbuffer); + if (SetClipboardData(CF_UNICODETEXT, clipbuffer) == NULL) + return false; + CloseClipboard(); + return true; + } + else return false; +} + +bool CCommon::WhenStart() +{ + int tick_count = GetTickCount(); + return (tick_count < 60000); +} diff --git a/src/TrafficMonitor/TrafficMonitor/Common.h b/src/TrafficMonitor/TrafficMonitor/Common.h new file mode 100644 index 0000000..dca781c --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/Common.h @@ -0,0 +1,105 @@ +#pragma once + +//ijһʷ +struct HistoryTraffic +{ + int year; + int month; + int day; + unsigned kBytes; //ʹõKBΪλ + + //ȽHistoryTrafficڣaʱb򷵻true + static bool DateGreater(const HistoryTraffic& a, const HistoryTraffic& b) + { + if (a.year != b.year) + return a.year > b.year; + else if (a.month != b.month) + return a.month > b.month; + else if (a.day != b.day) + return a.day > b.day; + else + return false; + } + + //жHistoryTrafficǷ + static bool DateEqual(const HistoryTraffic& a, const HistoryTraffic& b) + { + return a.year == b.year && a.month == b.month && a.day == b.day; + } +}; + +class CCommon +{ +public: + CCommon(); + ~CCommon(); + //const char*ַתɿַַ + static wstring StrToUnicode(const char* str); + + static string UnicodeToStr(const wchar_t* wstr); + + //һintдiniļɹ򷵻true + static bool WritePrivateProfileIntW(const wchar_t * AppName, const wchar_t * KeyName, int value, const wchar_t * Path); + + //ڴСתKBMBGBΪλַ + static CString DataSizeToString(unsigned int size); + + static CString KBytesToString(unsigned int kb_size); + + //FILETIMEṹʱ + static __int64 CompareFileTime2(FILETIME time1, FILETIME time2); + + //һ־Ϣstr_textд뵽file_pathļ + static void WriteLog(const char* str_text, LPCTSTR file_path); + + /* + ܣָļָĿ¼´ݷʽ + + lpszLnkFileDir ָĿ¼ΪNULL + lpszFileName ָļΪNULLʾǰ̵EXEļ + lpszLnkFileName ݷʽƣΪNULLʾEXEļ + wHotkey Ϊ0ʾÿݼ + pszDescription ע + iShowCmd зʽĬΪ洰 + */ + static BOOL CreateFileShortcut(LPCTSTR lpszLnkFileDir, LPCTSTR lpszFileName = NULL, LPCTSTR lpszLnkFileName = NULL, LPCTSTR lpszWorkDir = NULL, WORD wHotkey = 0, LPCTSTR lpszDescription = NULL, int iShowCmd = SW_SHOWNORMAL); + + //ȡʼ˵геġĿ¼· + static wstring GetStartUpPath(); + + //ȡpath·µļļУļļƱfilesС + static void GetFiles(const wchar_t* path, vector& files); + + //жһļǷ + static bool FileExist(LPCTSTR file_name); + + //SYSTEMTIMEṹʱIJa-bֻʱ֡룩 + static SYSTEMTIME CompareSystemTime(SYSTEMTIME a, SYSTEMTIME b); + + static wstring GetExePath(); + + //ָλûı + static void DrawWindowText(CDC* pDC, CRect rect, LPCTSTR lpszString, COLORREF color, COLORREF back_color); + + //ΪһStaticؼָɫ + static void FillStaticColor(CStatic& static_ctr, COLORREF color); + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ƣIsForegroundFullscreen + * ˵жϵǰûǰ̨Ƿȫġ + * ˵ + * ˵trueǡ + false + * ̰߳ȫ + * IsForegroundFullscreen ()ʾжϵǰûǰ̨Ƿȫġ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + static bool IsForegroundFullscreen(); + + //һַ浽 + static bool CopyStringToClipboard(const wstring& str); + + //жǷտڸտ1ڷtrue򷵻false + static bool WhenStart(); + +}; + diff --git a/src/TrafficMonitor/TrafficMonitor/DonateDlg.cpp b/src/TrafficMonitor/TrafficMonitor/DonateDlg.cpp new file mode 100644 index 0000000..bb5c01d --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/DonateDlg.cpp @@ -0,0 +1,52 @@ +// DonateDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "DonateDlg.h" +#include "afxdialogex.h" + + +// CDonateDlg Ի + +IMPLEMENT_DYNAMIC(CDonateDlg, CDialog) + +CDonateDlg::CDonateDlg(CWnd* pParent /*=NULL*/) + : CDialog(IDD_DONATE_DIALOG, pParent) +{ + +} + +CDonateDlg::~CDonateDlg() +{ +} + +void CDonateDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_DONATE_PIC, m_donate_pic); +} + + +BEGIN_MESSAGE_MAP(CDonateDlg, CDialog) +END_MESSAGE_MAP() + + +// CDonateDlg Ϣ + + +BOOL CDonateDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + CWindowDC dc(this); + HDC hDC = dc.GetSafeHdc(); + int dpi = GetDeviceCaps(hDC, LOGPIXELSY); + int side = 304 * dpi / 96; + + m_donate_pic.SetWindowPos(&CWnd::wndTop, 0, 0, side, side, SWP_NOMOVE); //ĿؼĿ͸ + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} diff --git a/src/TrafficMonitor/TrafficMonitor/DonateDlg.h b/src/TrafficMonitor/TrafficMonitor/DonateDlg.h new file mode 100644 index 0000000..2a8e8a0 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/DonateDlg.h @@ -0,0 +1,28 @@ +#pragma once +#include "afxwin.h" + + +// CDonateDlg Ի + +class CDonateDlg : public CDialog +{ + DECLARE_DYNAMIC(CDonateDlg) + +public: + CDonateDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CDonateDlg(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DONATE_DIALOG }; +#endif + +protected: + CStatic m_donate_pic; + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/HistoryTrafficDlg.cpp b/src/TrafficMonitor/TrafficMonitor/HistoryTrafficDlg.cpp new file mode 100644 index 0000000..435fe1b --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/HistoryTrafficDlg.cpp @@ -0,0 +1,78 @@ +// HistoryTrafficDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "HistoryTrafficDlg.h" +#include "afxdialogex.h" + + +// CHistoryTrafficDlg Ի + +IMPLEMENT_DYNAMIC(CHistoryTrafficDlg, CDialog) + +CHistoryTrafficDlg::CHistoryTrafficDlg(deque& history_traffics, CWnd* pParent /*=NULL*/) + : CDialog(IDD_HISTORY_TRAFFIC_DIALOG, pParent), m_history_traffics(history_traffics) +{ + +} + +CHistoryTrafficDlg::~CHistoryTrafficDlg() +{ +} + +void CHistoryTrafficDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_HISTORY_INFO_LIST, m_history_list); +} + + +BEGIN_MESSAGE_MAP(CHistoryTrafficDlg, CDialog) +END_MESSAGE_MAP() + + +// CHistoryTrafficDlg Ϣ + + +BOOL CHistoryTrafficDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + //ȡdpi + CWindowDC dc(this); + HDC hDC = dc.GetSafeHdc(); + int dpi = GetDeviceCaps(hDC, LOGPIXELSY); + + //ʼбؼ + CRect rect; + m_history_list.GetClientRect(rect); + m_history_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); + int width0, width1; + width0 = rect.Width() / 5 * 2; + width1 = rect.Width() - width0 - 21 * dpi / 96; + m_history_list.InsertColumn(0, _T(""), LVCFMT_LEFT, width0); //0 + m_history_list.InsertColumn(1, _T("ʹõϴ+أ"), LVCFMT_LEFT, width1); //1 + + for (int i{}; i& history_traffics, CWnd* pParent = NULL); // ׼캯 + virtual ~CHistoryTrafficDlg(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_HISTORY_TRAFFIC_DIALOG }; +#endif + +protected: + CListCtrl m_history_list; + deque& m_history_traffics; + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.cpp b/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.cpp new file mode 100644 index 0000000..2db0c02 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.cpp @@ -0,0 +1,215 @@ +// MainWndSettingsDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "MainWndSettingsDlg.h" +#include "afxdialogex.h" + + +// CMainWndSettingsDlg Ի + +IMPLEMENT_DYNAMIC(CMainWndSettingsDlg, CDialogEx) + +CMainWndSettingsDlg::CMainWndSettingsDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_MAIN_WND_SETTINGS_DIALOG, pParent) +{ + +} + +CMainWndSettingsDlg::~CMainWndSettingsDlg() +{ +} + +void CMainWndSettingsDlg::DrawStaticColor() +{ + CCommon::FillStaticColor(m_color_static, m_text_color); +} + +void CMainWndSettingsDlg::DoDataExchange(CDataExchange* pDX) +{ + DDX_Control(pDX, IDC_TEXT_COLOR_STATIC, m_color_static); + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CMainWndSettingsDlg, CDialogEx) + ON_EN_CHANGE(IDC_UPLOAD_EDIT, &CMainWndSettingsDlg::OnEnChangeUploadEdit) + ON_EN_CHANGE(IDC_DOWNLOAD_EDIT, &CMainWndSettingsDlg::OnEnChangeDownloadEdit) + ON_EN_CHANGE(IDC_CPU_EDIT, &CMainWndSettingsDlg::OnEnChangeCpuEdit) + ON_EN_CHANGE(IDC_MEMORY_EDIT, &CMainWndSettingsDlg::OnEnChangeMemoryEdit) + //ON_WM_TIMER() + //ON_STN_CLICKED(IDC_TEXT_COLOR_STATIC, &CMainWndSettingsDlg::OnStnClickedTextColorStatic) + ON_BN_CLICKED(IDC_SET_COLOR_BUTTON1, &CMainWndSettingsDlg::OnBnClickedSetColorButton1) + ON_BN_CLICKED(IDC_SET_DEFAULT_BUTTON, &CMainWndSettingsDlg::OnBnClickedSetDefaultButton) + ON_BN_CLICKED(IDC_SET_FONT_BUTTON, &CMainWndSettingsDlg::OnBnClickedSetFontButton) + ON_BN_CLICKED(IDC_SWITCH_UP_DOWN_CHECK, &CMainWndSettingsDlg::OnBnClickedSwitchUpDownCheck) + ON_BN_CLICKED(IDC_FULLSCREEN_HIDE_CHECK, &CMainWndSettingsDlg::OnBnClickedFullscreenHideCheck) +END_MESSAGE_MAP() + + +// CMainWndSettingsDlg Ϣ + + +BOOL CMainWndSettingsDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: ڴӶijʼ + SetBackgroundColor(RGB(255, 255, 255)); + + //ʼؼ״̬ + SetDlgItemText(IDC_FONT_NAME_EDIT, m_font_name); + wchar_t buff[16]; + swprintf_s(buff, L"%d", m_font_size); + SetDlgItemText(IDC_FONT_SIZE_EDIT, buff); + + SetDlgItemText(IDC_UPLOAD_EDIT, m_up_string.c_str()); + SetDlgItemText(IDC_DOWNLOAD_EDIT, m_down_string.c_str()); + SetDlgItemText(IDC_CPU_EDIT, m_cpu_string.c_str()); + SetDlgItemText(IDC_MEMORY_EDIT, m_memory_string.c_str()); + + ((CButton*)GetDlgItem(IDC_SWITCH_UP_DOWN_CHECK))->SetCheck(m_swap_up_down); + ((CButton*)GetDlgItem(IDC_FULLSCREEN_HIDE_CHECK))->SetCheck(m_hide_main_wnd_when_fullscreen); + + //SetTimer(11, 50, NULL); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void CMainWndSettingsDlg::OnEnChangeUploadEdit() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_UPLOAD_EDIT, tmp); + m_up_string = tmp; +} + + +void CMainWndSettingsDlg::OnEnChangeDownloadEdit() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_DOWNLOAD_EDIT, tmp); + m_down_string = tmp; +} + + +void CMainWndSettingsDlg::OnEnChangeCpuEdit() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_CPU_EDIT, tmp); + m_cpu_string = tmp; +} + + +void CMainWndSettingsDlg::OnEnChangeMemoryEdit() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_MEMORY_EDIT, tmp); + m_memory_string = tmp; +} + + +//void CMainWndSettingsDlg::OnTimer(UINT_PTR nIDEvent) +//{ +// // TODO: ڴϢ/Ĭֵ +// if (nIDEvent == 11) +// { +// CCommon::FillStaticColor(m_color_static, m_text_color); +// KillTimer(11); +// } +// CDialogEx::OnTimer(nIDEvent); +//} + + +//void CMainWndSettingsDlg::OnStnClickedTextColorStatic() +//{ +// // TODO: ڴӿؼ֪ͨ +//} + + +void CMainWndSettingsDlg::OnBnClickedSetColorButton1() +{ + // TODO: ڴӿؼ֪ͨ + CColorDialog colorDlg(m_text_color, 0, this); + if (colorDlg.DoModal() == IDOK) + { + m_text_color = colorDlg.GetColor(); + DrawStaticColor(); + } +} + + +void CMainWndSettingsDlg::OnBnClickedSetDefaultButton() +{ + // TODO: ڴӿؼ֪ͨ + m_up_string = L"ϴ: "; + m_down_string = L": "; + m_cpu_string = L"CPU: "; + m_memory_string = L"ڴ: "; + SetDlgItemText(IDC_UPLOAD_EDIT, m_up_string.c_str()); + SetDlgItemText(IDC_DOWNLOAD_EDIT, m_down_string.c_str()); + SetDlgItemText(IDC_CPU_EDIT, m_cpu_string.c_str()); + SetDlgItemText(IDC_MEMORY_EDIT, m_memory_string.c_str()); +} + + +void CMainWndSettingsDlg::OnBnClickedSetFontButton() +{ + // TODO: ڴӿؼ֪ͨ + CFont font; + font.CreatePointFont(m_font_size * 10, m_font_name); + LOGFONT lf{}; //LOGFONT + font.GetLogFont(&lf); + CFontDialog fontDlg(&lf); //Ի򣬳ʼѡΪ֮ǰ + if (IDOK == fontDlg.DoModal()) // ʾԻ + { + //ȡϢ + m_font_name = fontDlg.GetFaceName(); + m_font_size = fontDlg.GetSize() / 10; + //Ϣʾ + SetDlgItemText(IDC_FONT_NAME_EDIT, m_font_name); + wchar_t buff[16]; + swprintf_s(buff, L"%d", m_font_size); + SetDlgItemText(IDC_FONT_SIZE_EDIT, buff); + } +} + + +void CMainWndSettingsDlg::OnBnClickedSwitchUpDownCheck() +{ + // TODO: ڴӿؼ֪ͨ + m_swap_up_down = (((CButton*)GetDlgItem(IDC_SWITCH_UP_DOWN_CHECK))->GetCheck() != 0); +} + + +void CMainWndSettingsDlg::OnBnClickedFullscreenHideCheck() +{ + // TODO: ڴӿؼ֪ͨ + m_hide_main_wnd_when_fullscreen = (((CButton*)GetDlgItem(IDC_FULLSCREEN_HIDE_CHECK))->GetCheck() != 0); +} diff --git a/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.h b/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.h new file mode 100644 index 0000000..2bcc0c8 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/MainWndSettingsDlg.h @@ -0,0 +1,51 @@ +#pragma once + + +// CMainWndSettingsDlg Ի + +class CMainWndSettingsDlg : public CDialogEx +{ + DECLARE_DYNAMIC(CMainWndSettingsDlg) + +public: + CMainWndSettingsDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CMainWndSettingsDlg(); + + //ѡ + CString m_font_name; + int m_font_size; + COLORREF m_text_color; + wstring m_up_string; //ĬΪϴ: + wstring m_down_string; //ĬΪ: + wstring m_cpu_string; //ĬΪCPU: + wstring m_memory_string; //ĬΪڴ: + bool m_swap_up_down; //Ƿ񽻻ϴصλ + bool m_hide_main_wnd_when_fullscreen; //гȫʱ + + void DrawStaticColor(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_MAIN_WND_SETTINGS_DIALOG }; +#endif + +protected: + CStatic m_color_static; + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnEnChangeUploadEdit(); + afx_msg void OnEnChangeDownloadEdit(); + afx_msg void OnEnChangeCpuEdit(); + afx_msg void OnEnChangeMemoryEdit(); +// afx_msg void OnTimer(UINT_PTR nIDEvent); +// afx_msg void OnStnClickedTextColorStatic(); + afx_msg void OnBnClickedSetColorButton1(); + afx_msg void OnBnClickedSetDefaultButton(); + afx_msg void OnBnClickedSetFontButton(); + afx_msg void OnBnClickedSwitchUpDownCheck(); + afx_msg void OnBnClickedFullscreenHideCheck(); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.cpp b/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.cpp new file mode 100644 index 0000000..9a64ab3 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.cpp @@ -0,0 +1,251 @@ +// CNetworkInfoDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "NetworkInfoDlg.h" +#include "afxdialogex.h" + + +// CNetworkInfoDlg Ի + +IMPLEMENT_DYNAMIC(CNetworkInfoDlg, CDialog) + +CNetworkInfoDlg::CNetworkInfoDlg(MIB_IFROW network_info, CWnd* pParent /*=NULL*/) + : CDialog(IDD_NETWORK_INFO_DIALOG, pParent), m_network_info(network_info) +{ + +} + +CNetworkInfoDlg::~CNetworkInfoDlg() +{ +} + + +void CNetworkInfoDlg::GetIPAddress() +{ + PIP_ADAPTER_INFO pIpAdapterInfo = new IP_ADAPTER_INFO(); //PIP_ADAPTER_INFOṹָ洢Ϣ + unsigned long stSize = sizeof(IP_ADAPTER_INFO); //õṹС,GetAdaptersInfo + int nRel = GetAdaptersInfo(pIpAdapterInfo, &stSize); //GetAdaptersInfo,pIpAdapterInfoָ;stSizeһҲһ + + if (ERROR_BUFFER_OVERFLOW == nRel) + { + //صERROR_BUFFER_OVERFLOW + //˵GetAdaptersInfoݵڴռ䲻,ͬʱ䴫stSize,ʾҪĿռС + //Ҳ˵ΪʲôstSizeһҲһ + delete pIpAdapterInfo; //ͷԭڴռ + pIpAdapterInfo = (PIP_ADAPTER_INFO)new BYTE[stSize]; //ڴռ洢Ϣ + nRel = GetAdaptersInfo(pIpAdapterInfo, &stSize); //ٴεGetAdaptersInfo,pIpAdapterInfoָ + } + + PIP_ADAPTER_INFO pIpAdapterInfoHead = pIpAdapterInfo; //pIpAdapterInfoеһԪصĵַ + if (ERROR_SUCCESS == nRel) + { + string current_network_descr{ (const char*)m_network_info.bDescr }; //MIB_IFROWṹеĵǰѡеӵ + //ȡϢ + //ж,ͨѭҵǰҪʾ + while (pIpAdapterInfo) + { + if(current_network_descr.find(pIpAdapterInfo->Description) != string::npos) + { + m_ip_address = CCommon::StrToUnicode(pIpAdapterInfo->IpAddressList.IpAddress.String); + m_subnet_mask = CCommon::StrToUnicode(pIpAdapterInfo->IpAddressList.IpMask.String); + m_default_gateway = CCommon::StrToUnicode(pIpAdapterInfo->GatewayList.IpAddress.String); + break; + } + pIpAdapterInfo = pIpAdapterInfo->Next; + } + } + //ͷڴռ + if (pIpAdapterInfoHead) + { + delete pIpAdapterInfoHead; + } +} + +void CNetworkInfoDlg::ShowInfo() +{ + CString temp; + m_info_list.InsertItem(0, _T("ӿ")); + m_info_list.SetItemText(0, 1, m_network_info.wszName); + + m_info_list.InsertItem(1, _T("ӿ")); + m_info_list.SetItemText(1, 1, CCommon::StrToUnicode((const char*)m_network_info.bDescr).c_str()); + + m_info_list.InsertItem(2, _T("")); + switch (m_network_info.dwType) + { + case IF_TYPE_OTHER: temp = _T(""); break; + case IF_TYPE_ETHERNET_CSMACD: temp = _T("̫"); break; + case IF_TYPE_ISO88025_TOKENRING: temp = _T("ƻ"); break; + case IF_TYPE_FDDI: temp = _T("˷ֲʽݽӿ (FDDI) "); break; + case IF_TYPE_PPP: temp = _T("PPP "); break; + case IF_TYPE_SOFTWARE_LOOPBACK: temp = _T(""); break; + case IF_TYPE_ATM: temp = _T("ATM "); break; + case IF_TYPE_IEEE80211: temp = _T("IEEE 802.11 "); break; + case IF_TYPE_TUNNEL: temp = _T("ͷװ"); break; + case IF_TYPE_IEEE1394: temp = _T("IEEE 1394 (Firewire) ܴ"); break; + case IF_TYPE_IEEE80216_WMAN: temp = _T(" WiMax 豸ƶ"); break; + case IF_TYPE_WWANPP: temp = _T(" GSM 豸ƶ"); break; + case IF_TYPE_WWANPP2: temp = _T(" CDMA 豸ƶ"); break; + default: temp = _T("δ֪"); break; + } + m_info_list.SetItemText(2, 1, temp); + + //m_info_list.InsertItem(3, _T("䵥λС")); + //temp.Format(_T("%u"), m_network_info.dwMtu); + //m_info_list.SetItemText(3, 1, temp); + + m_info_list.InsertItem(3, _T("ٶ")); + temp.Format(_T("%dMbps"), m_network_info.dwSpeed / 1000000); + m_info_list.SetItemText(3, 1, temp); + + m_info_list.InsertItem(4, _T("ַ")); + temp = _T(""); + char buff[3]; + for (int 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]); + temp += buff; + if (i != m_network_info.dwPhysAddrLen - 1) + temp += _T('-'); + } + m_info_list.SetItemText(4, 1, temp); + + m_info_list.InsertItem(5, _T("IPַ")); + m_info_list.SetItemText(5, 1, m_ip_address.c_str()); + + m_info_list.InsertItem(6, _T("")); + m_info_list.SetItemText(6, 1, m_subnet_mask.c_str()); + + m_info_list.InsertItem(7, _T("Ĭ")); + m_info_list.SetItemText(7, 1, m_default_gateway.c_str()); + + ////temp.Format(_T("ַȣ%d\r\n"), m_network_info.dwPhysAddrLen); + ////out_info += temp; + ////temp = _T("ַ"); + ////temp += StrToUnicode((const char*)m_network_info.bPhysAddr).c_str(); + ////out_info += temp; + ////out_info += _T("\r\n"); + + //m_info_list.InsertItem(5, _T("Ա״̬")); + //m_info_list.SetItemText(5, 1, m_network_info.dwAdminStatus ? _T("") : _T("")); + + m_info_list.InsertItem(8, _T("״̬")); + switch (m_network_info.dwOperStatus) + { + case IF_OPER_STATUS_NON_OPERATIONAL: temp = _T("LAN ѱ"); break; + case IF_OPER_STATUS_UNREACHABLE: temp = _T("WAN δ"); break; + case IF_OPER_STATUS_DISCONNECTED: temp = _T("¶Ͽӻ"); break; + case IF_OPER_STATUS_CONNECTING: temp = _T("WAN "); break; + case IF_OPER_STATUS_CONNECTED: temp = _T("WAN ӵԶ̶Եȷ"); break; + case IF_OPER_STATUS_OPERATIONAL: temp = _T("LAN "); break; + default: temp = _T("δ֪״̬"); break; + } + m_info_list.SetItemText(8, 1, temp); + + m_info_list.InsertItem(9, _T("ѽֽ")); + temp.Format(_T("%u (%s)"), m_network_info.dwInOctets, CCommon::DataSizeToString(m_network_info.dwInOctets)); + m_info_list.SetItemText(9, 1, temp); + + m_info_list.InsertItem(10, _T("ѷֽ")); + temp.Format(_T("%u (%s)"), m_network_info.dwOutOctets, CCommon::DataSizeToString(m_network_info.dwOutOctets)); + m_info_list.SetItemText(10, 1, temp); + + m_info_list.InsertItem(11, _T("Գѽֽ")); + temp.Format(_T("%u (%s)"), m_in_bytes, CCommon::DataSizeToString(m_in_bytes)); + m_info_list.SetItemText(11, 1, temp); + + m_info_list.InsertItem(12, _T("Գѷֽ")); + temp.Format(_T("%u (%s)"), m_out_bytes, CCommon::DataSizeToString(m_out_bytes)); + m_info_list.SetItemText(12, 1, temp); + + m_info_list.InsertItem(13, _T("ʱ")); + SYSTEMTIME current_time, time; + GetLocalTime(¤t_time); + time = CCommon::CompareSystemTime(current_time, m_start_time); + temp.Format(_T("%dСʱ%d%d"), time.wHour, time.wMinute, time.wSecond); + m_info_list.SetItemText(13, 1, temp); +} + +void CNetworkInfoDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_INFO_LIST1, m_info_list); +} + + +BEGIN_MESSAGE_MAP(CNetworkInfoDlg, CDialog) + ON_COMMAND(ID_COPY_TEXT, &CNetworkInfoDlg::OnCopyText) + ON_NOTIFY(NM_RCLICK, IDC_INFO_LIST1, &CNetworkInfoDlg::OnNMRClickInfoList1) +END_MESSAGE_MAP() + + +// CNetworkInfoDlg Ϣ + + +BOOL CNetworkInfoDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + + //ȡdpi + CWindowDC dc(this); + HDC hDC = dc.GetSafeHdc(); + int dpi = GetDeviceCaps(hDC, LOGPIXELSY); + + //ȡIPַ + GetIPAddress(); + + //ʼбؼ + CRect rect; + m_info_list.GetClientRect(rect); + m_info_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); + int width0, width1; + width0 = rect.Width() / 4; + width1 = rect.Width() - width0 - 21 * dpi / 96; + m_info_list.InsertColumn(0, _T("Ŀ"), LVCFMT_LEFT, width0); //0 + m_info_list.InsertColumn(1, _T("ֵ"), LVCFMT_LEFT, width1); //1 + + //ʾбеϢ + ShowInfo(); + + //SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ȡö + m_info_list.GetToolTips()->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + + m_menu.LoadMenu(IDR_INFO_MENU); //װҼ˵ + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void CNetworkInfoDlg::OnCopyText() +{ + // TODO: ڴ + if (!CCommon::CopyStringToClipboard(wstring(m_selected_string))) + MessageBox(_T("Ƶʧܣ"), NULL, MB_ICONWARNING); +} + + +void CNetworkInfoDlg::OnNMRClickInfoList1(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); + // TODO: ڴӿؼ֪ͨ + + //ȡı + int item, sub_item; + item = pNMItemActivate->iItem; + sub_item = pNMItemActivate->iSubItem; + m_selected_string = m_info_list.GetItemText(item, sub_item); + + //Ҽ˵ + CMenu* pContextMenu = m_menu.GetSubMenu(0); //ȡһ˵ + CPoint point1; //һȷλõλ + GetCursorPos(&point1); //ȡǰλãԱʹò˵Ը + pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point1.x, point1.y, this); //ָλʾ˵ + + *pResult = 0; +} diff --git a/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.h b/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.h new file mode 100644 index 0000000..493c702 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/NetworkInfoDlg.h @@ -0,0 +1,48 @@ +#pragma once +#include"Common.h" +#include "afxcmn.h" + +// CNetworkInfoDlg Ի + +class CNetworkInfoDlg : public CDialog +{ + DECLARE_DYNAMIC(CNetworkInfoDlg) + +public: + CNetworkInfoDlg(MIB_IFROW network_info ,CWnd* pParent = NULL); // ׼캯 + virtual ~CNetworkInfoDlg(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_NETWORK_INFO_DIALOG }; +#endif + + unsigned int m_in_bytes; //ǰ鿴ѽֽ + unsigned int m_out_bytes; //ǰ鿴ѷֽ + + SYSTEMTIME m_start_time; //ʱ + +protected: + + MIB_IFROW m_network_info; //ǰ鿴Ϣ + wstring m_ip_address{ L"-.-.-.-" }; //IPַ + wstring m_subnet_mask{ L"-.-.-.-" }; // + wstring m_default_gateway{ L"-.-.-.-" }; //Ĭ + + CListCtrl m_info_list; + CMenu m_menu; + + CString m_selected_string; + + void GetIPAddress(); //ȡIPַ + void ShowInfo(); + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() + + virtual BOOL OnInitDialog(); +public: + afx_msg void OnCopyText(); + afx_msg void OnNMRClickInfoList1(NMHDR *pNMHDR, LRESULT *pResult); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/OptionsDlg.cpp b/src/TrafficMonitor/TrafficMonitor/OptionsDlg.cpp new file mode 100644 index 0000000..5375124 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/OptionsDlg.cpp @@ -0,0 +1,121 @@ +// OptionsDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "OptionsDlg.h" +#include "afxdialogex.h" + + +// COptionsDlg Ի + +IMPLEMENT_DYNAMIC(COptionsDlg, CDialog) + +COptionsDlg::COptionsDlg(int tab, CWnd* pParent /*=NULL*/) + : CDialog(IDD_OPTIONS_DIALOG, pParent), m_tab_selected{ tab } +{ + +} + +COptionsDlg::~COptionsDlg() +{ +} + +void COptionsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_TAB1, m_tab); +} + + +BEGIN_MESSAGE_MAP(COptionsDlg, CDialog) + ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &COptionsDlg::OnTcnSelchangeTab1) + ON_WM_TIMER() +END_MESSAGE_MAP() + + +// COptionsDlg Ϣ + + +BOOL COptionsDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + //ǩ + m_tab.InsertItem(0, _T("")); + m_tab.InsertItem(1, _T("")); + //ӶԻ + m_tab1_dlg.Create(IDD_MAIN_WND_SETTINGS_DIALOG, &m_tab); + m_tab2_dlg.Create(IDD_TASKBAR_SETTINGS_DIALOG, &m_tab); + //ӶԻĴСλ + CRect rect; + m_tab.GetClientRect(rect); + CRect rcTabItem; + m_tab.GetItemRect(0, rcTabItem); + rect.top += rcTabItem.Height() + 4; + rect.left += 4; + rect.bottom -= 4; + rect.right -= 4; + m_tab1_dlg.MoveWindow(&rect); + m_tab2_dlg.MoveWindow(&rect); + //Ĭѡеıǩ + switch (m_tab_selected) + { + case 0: + m_tab1_dlg.ShowWindow(SW_SHOW); + SetTimer(TIMER_ID1, 50, NULL); + break; + case 1: + m_tab2_dlg.ShowWindow(SW_SHOW); + SetTimer(TIMER_ID2, 50, NULL); + break; + } + m_tab.SetCurFocus(m_tab_selected); + //m_tab.SetCurSel(m_tab_selected); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void COptionsDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult) +{ + // TODO: ڴӿؼ֪ͨ + m_tab_selected = m_tab.GetCurSel(); + switch (m_tab_selected) + { + case 0: + m_tab1_dlg.ShowWindow(SW_SHOW); + m_tab2_dlg.ShowWindow(SW_HIDE); + m_tab1_dlg.SetFocus(); + SetTimer(TIMER_ID1, 50, NULL); //˵1ѡӳ30ɫؼ + break; + case 1: + m_tab2_dlg.ShowWindow(SW_SHOW); + m_tab1_dlg.ShowWindow(SW_HIDE); + m_tab2_dlg.SetFocus(); + SetTimer(TIMER_ID2, 50, NULL); //˵2ѡӳ30ɫؼ + break; + } + *pResult = 0; +} + + +void COptionsDlg::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: ڴϢ/Ĭֵ + if (nIDEvent == TIMER_ID1) + { + m_tab1_dlg.DrawStaticColor(); + KillTimer(TIMER_ID1); + } + + if (nIDEvent == TIMER_ID2) + { + m_tab2_dlg.DrawStaticColor(); + KillTimer(TIMER_ID2); + } + + CDialog::OnTimer(nIDEvent); +} diff --git a/src/TrafficMonitor/TrafficMonitor/OptionsDlg.h b/src/TrafficMonitor/TrafficMonitor/OptionsDlg.h new file mode 100644 index 0000000..333881e --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/OptionsDlg.h @@ -0,0 +1,38 @@ +#pragma once +#include "MainWndSettingsDlg.h" +#include "TaskBarSettingsDlg.h" +#include "afxcmn.h" + +// COptionsDlg Ի + +#define TIMER_ID1 1120 +#define TIMER_ID2 1121 + +class COptionsDlg : public CDialog +{ + DECLARE_DYNAMIC(COptionsDlg) + +public: + COptionsDlg(int tab = 0, CWnd* pParent = NULL); // ׼캯 + virtual ~COptionsDlg(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_OPTIONS_DIALOG }; +#endif + + CMainWndSettingsDlg m_tab1_dlg; + CTaskBarSettingsDlg m_tab2_dlg; + +protected: + CTabCtrl m_tab; + int m_tab_selected; + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnTimer(UINT_PTR nIDEvent); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/ReadMe.txt b/src/TrafficMonitor/TrafficMonitor/ReadMe.txt new file mode 100644 index 0000000..b095322 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/ReadMe.txt @@ -0,0 +1,67 @@ +================================================================================ + MICROSOFT 基础类库 : TrafficMonitor 项目概述 +=============================================================================== + +应用程序向导已为您创建了此 TrafficMonitor 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 + +本文件概要介绍组成 TrafficMonitor 应用程序的每个文件的内容。 + +TrafficMonitor.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +TrafficMonitor.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +TrafficMonitor.h + 这是应用程序的主头文件。 + 其中包括其他项目特定的标头(包括 Resource.h),并声明 CTrafficMonitorApp 应用程序类。 + +TrafficMonitor.cpp + 这是包含应用程序类 CTrafficMonitorApp 的主应用程序源文件。 + +TrafficMonitor.rc + 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 + +res\TrafficMonitor.ico + 这是用作应用程序图标的图标文件。此图标包括在主资源文件 TrafficMonitor.rc 中。 + +res\TrafficMonitor.rc2 + 此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 + + +///////////////////////////////////////////////////////////////////////////// + +应用程序向导创建一个对话框类: + +TrafficMonitorDlg.h、TrafficMonitorDlg.cpp - 对话框 + 这些文件包含 CTrafficMonitorDlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 TrafficMonitor.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。 + +///////////////////////////////////////////////////////////////////////////// + +其他功能: + +ActiveX 控件 + 该应用程序包含对使用 ActiveX 控件的支持。 + +///////////////////////////////////////////////////////////////////////////// + +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 TrafficMonitor.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +Resource.h + 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 + +TrafficMonitor.manifest + Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 +///////////////////////////////////////////////////////////////////////////// + +其他注释: + +应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 + +如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 +有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/src/TrafficMonitor/TrafficMonitor/SkinDlg.cpp b/src/TrafficMonitor/TrafficMonitor/SkinDlg.cpp new file mode 100644 index 0000000..0ebd053 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/SkinDlg.cpp @@ -0,0 +1,119 @@ +// SkinDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "SkinDlg.h" +#include "afxdialogex.h" + + +// CSkinDlg Ի + +IMPLEMENT_DYNAMIC(CSkinDlg, CDialogEx) + +CSkinDlg::CSkinDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_SKIN_DIALOG, pParent) +{ + +} + +CSkinDlg::~CSkinDlg() +{ +} + +void CSkinDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO1, m_select_box); + DDX_Control(pDX, IDC_STATIC_SKIN_S, m_skin_preview_s); + DDX_Control(pDX, IDC_STATIC_SKIN_L, m_skin_preview_l); + // DDX_Control(pDX, IDC_STATIC_TEXT1, m_preview_text_s); + // DDX_Control(pDX, IDC_STATIC_TEXT2, m_preview_text_l); +} + + +void CSkinDlg::ShowPreview() +{ + //ʾСߴԤͼ + m_skin_preview_s.SetWindowPos(&CWnd::wndTop, 0, 0, m_skin_width, m_skin_height_s, SWP_NOMOVE); //ĿؼĿ͸ + m_image = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected]+ L"\\background.bmp").c_str(), IMAGE_BITMAP, m_skin_width, m_skin_height_s, LR_LOADFROMFILE); + m_skin_preview_s.SetBitmap(m_image); //ΪCStaticؼͼƬ + //ʾߴԤͼ + m_skin_preview_l.SetWindowPos(&CWnd::wndTop, 0, 0, m_skin_width, m_skin_height_l, SWP_NOMOVE); + m_image = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\background_l.bmp").c_str(), IMAGE_BITMAP, m_skin_width, m_skin_height_l, LR_LOADFROMFILE); + m_skin_preview_l.SetBitmap(m_image); + //ȡǰƤɫ + m_text_color = GetPrivateProfileInt(_T("skin"), _T("text_color"), 0, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\skin.ini").c_str()); + //ȡƤ + wchar_t buff[64]; + GetPrivateProfileString(_T("skin"), _T("skin_author"), _T("unknow"), buff, 64, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\skin.ini").c_str()); + SetDlgItemText(IDC_SKIN_INFO, (wstring(L"Ƥߣ") + buff).c_str()); +} + +void CSkinDlg::SetPreviewText(CStatic& static_preview) +{ + CDC* pDC = static_preview.GetDC(); + pDC->SetTextColor(m_text_color); + pDC->SetBkMode(TRANSPARENT); + pDC->SelectObject(this->GetFont()); + CRect rect; + static_preview.GetClientRect(&rect); + rect.left += 10; + DrawThemeParentBackground(m_hWnd, pDC->GetSafeHdc(), &rect); //ػؼԽص + pDC->DrawText(_T("ʾı1234ABCD"), rect, DT_VCENTER | DT_SINGLELINE); + ReleaseDC(pDC); +} + + +BEGIN_MESSAGE_MAP(CSkinDlg, CDialogEx) + ON_CBN_SELCHANGE(IDC_COMBO1, &CSkinDlg::OnCbnSelchangeCombo1) + ON_WM_TIMER() +END_MESSAGE_MAP() + + +// CSkinDlg Ϣ + +BOOL CSkinDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: ڴӶijʼ + //ʼѡ + for (const auto& skin_path : m_skins) + { + wstring skin_name; + size_t index = skin_path.find_last_of(L'\\'); + skin_name = skin_path.substr(index + 1); + m_select_box.AddString(skin_name.c_str()); + } + m_select_box.SetCurSel(m_skin_selected); + //ʾԤͼƬ + ShowPreview(); + + SetTimer(2345, 100, NULL); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void CSkinDlg::OnCbnSelchangeCombo1() +{ + // TODO: ڴӿؼ֪ͨ + m_skin_selected = m_select_box.GetCurSel(); + ShowPreview(); + //ʾʾı + SetPreviewText(m_skin_preview_s); + SetPreviewText(m_skin_preview_l); +} + + +void CSkinDlg::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: ڴϢ/Ĭֵ + SetPreviewText(m_skin_preview_s); + SetPreviewText(m_skin_preview_l); + KillTimer(2345); //ʱӦһκͽ + + CDialogEx::OnTimer(nIDEvent); +} diff --git a/src/TrafficMonitor/TrafficMonitor/SkinDlg.h b/src/TrafficMonitor/TrafficMonitor/SkinDlg.h new file mode 100644 index 0000000..8e1e159 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/SkinDlg.h @@ -0,0 +1,49 @@ +#pragma once +#include "afxwin.h" +#include"StaticEx.h" + +// CSkinDlg Ի + +class CSkinDlg : public CDialogEx +{ + DECLARE_DYNAMIC(CSkinDlg) + +public: + CSkinDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CSkinDlg(); + + vector m_skins; //Ƥļ· + int m_skin_selected; //ѡƤ + int m_skin_width; //Ԥͼ + int m_skin_height_s; //Ԥͼ߶ȣС + int m_skin_height_l; //Ԥͼ߶ȣ + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_SKIN_DIALOG }; +#endif + + COLORREF GetTextColor() const + { + return m_text_color; + } + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + COLORREF m_text_color; //ǰƤıɫ + CComboBox m_select_box; //ѡ + CStatic m_skin_preview_s; //ʾԤͼĿؼ + CStatic m_skin_preview_l; //ʾСԤͼĿؼ + HBITMAP m_image; //ͼƬ + //wstring m_skin_author; //Ƥ + + void ShowPreview(); //ʾƤԤ + void SetPreviewText(CStatic& static_preview); //Ԥ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnCbnSelchangeCombo1(); + afx_msg void OnTimer(UINT_PTR nIDEvent); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/StaticEx.cpp b/src/TrafficMonitor/TrafficMonitor/StaticEx.cpp new file mode 100644 index 0000000..8ab2e25 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/StaticEx.cpp @@ -0,0 +1,210 @@ +#include "stdafx.h" +#include "StaticEx.h" + + +CStaticEx::CStaticEx() +{ +} + +CStaticEx::CStaticEx(bool is_hyperlink) +{ + m_isHyperLink = is_hyperlink; +} + + +CStaticEx::~CStaticEx() +{ +} + +void CStaticEx::SetWindowTextEx(LPCTSTR lpszString) +{ + CDC* pDC = GetDC(); + pDC->SetTextColor(m_TextColor); + pDC->SetBkMode(TRANSPARENT); + pDC->SelectObject(this->GetFont()); + //int nTextLeft = 0, nTextTop = 0; //λ + CRect rect; + this->GetClientRect(&rect); + DrawThemeParentBackground(m_hWnd, pDC->GetSafeHdc(), &rect); //ػؼԽص + pDC->DrawText(lpszString, rect, DT_VCENTER | DT_SINGLELINE); + ReleaseDC(pDC); + m_text = lpszString; +} + +void CStaticEx::SetTextColor(COLORREF textColor) +{ + m_TextColor = textColor; + SetWindowTextEx(m_text); +} + +CString CStaticEx::GetString() const +{ + return m_text; +} + +void CStaticEx::SetURL(CString strURL) +{ + m_strURL = strURL; +} + +CString CStaticEx::GetURL() const +{ + return m_strURL; +} + + +LRESULT CStaticEx::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + // TODO: ڴרô/û + if (message == WM_SETTEXT) + { + CRect rect; + CDC* pDC = GetDC(); + GetClientRect(rect); + DrawThemeParentBackground(m_hWnd, pDC->GetSafeHdc(), &rect); + ReleaseDC(pDC); + } + return CStatic::DefWindowProc(message, wParam, lParam); +} +BEGIN_MESSAGE_MAP(CStaticEx, CStatic) + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONUP() + ON_WM_PAINT() + ON_WM_MOUSEHOVER() + ON_WM_MOUSELEAVE() + ON_WM_SETCURSOR() +END_MESSAGE_MAP() + + +void CStaticEx::OnMouseMove(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + if (m_isHyperLink) + { + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.hwndTrack = m_hWnd; + tme.dwFlags = TME_LEAVE | TME_HOVER; + tme.dwHoverTime = 1; + _TrackMouseEvent(&tme); + } + else + { + CStatic::OnMouseMove(nFlags, point); + } +} + + +void CStaticEx::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + if (m_isHyperLink) + { + if (m_strURL.IsEmpty()) + { + m_strURL = m_text; + } + ShellExecute(NULL, _T("open"), m_strURL, NULL, NULL, SW_SHOW); //򿪳 + } + else + { + CStatic::OnLButtonUp(nFlags, point); + } +} + + +void CStaticEx::OnPaint() +{ + CPaintDC dc(this); // device context for painting + // TODO: ڴ˴Ϣ + // ΪͼϢ CStatic::OnPaint() + if (m_isHyperLink) + { + CFont* pFont = GetFont(); + CFont m_Font; + if (pFont != NULL) + { + LOGFONT lf; + pFont->GetLogFont(&lf); + lf.lfUnderline = m_bHot; + if (m_Font.CreateFontIndirect(&lf)) + dc.SelectObject(m_Font); + } + dc.SetTextColor(RGB(0, 0, 255)); + dc.SetBkMode(TRANSPARENT); + ///׼ + CRect rect; + CBrush BGBrush, *pOldBrush; + this->GetClientRect(&rect); + // + COLORREF backColor = GetSysColor(COLOR_BTNFACE); + BGBrush.CreateSolidBrush(backColor); + pOldBrush = dc.SelectObject(&BGBrush); + dc.FillRect(&rect, &BGBrush); + dc.SelectObject(pOldBrush); + BGBrush.DeleteObject(); + /// + if (m_text.GetLength()>0) + { + dc.DrawText(m_text, rect, DT_VCENTER | DT_SINGLELINE); + } + m_Font.DeleteObject(); + } +} + + +void CStaticEx::OnMouseHover(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + if (m_isHyperLink && !m_bHot) + { + m_bHot = true; + Invalidate(); + } + else + { + CStatic::OnMouseHover(nFlags, point); + } +} + + +void CStaticEx::OnMouseLeave() +{ + // TODO: ڴϢ/Ĭֵ + if (m_isHyperLink) + { + m_bHot = false; + Invalidate(); + } + else + { + CStatic::OnMouseLeave(); + } +} + + +BOOL CStaticEx::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + // TODO: ڴϢ/Ĭֵ + if (m_isHyperLink && m_bHot) + { + ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(32649))); + return TRUE; + } + + return CStatic::OnSetCursor(pWnd, nHitTest, message); +} + + +void CStaticEx::PreSubclassWindow() +{ + // TODO: ڴרô/û + if (m_isHyperLink) + { + DWORD dwStyle = GetStyle(); + ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); + } + GetWindowText(m_text); + + CStatic::PreSubclassWindow(); +} diff --git a/src/TrafficMonitor/TrafficMonitor/StaticEx.h b/src/TrafficMonitor/TrafficMonitor/StaticEx.h new file mode 100644 index 0000000..1cb8390 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/StaticEx.h @@ -0,0 +1,38 @@ +//CStatic࣬ʵStaticؼɫ +//Լ˴ڱͼƬʱؼص⡣ +#pragma once +#include "afxwin.h" +class CStaticEx : + public CStatic +{ +public: + CStaticEx(); + CStaticEx(bool is_hyperlink); //캯ļؼıǷΪ + ~CStaticEx(); + + void SetWindowTextEx(LPCTSTR lpszString); //ΪؼɫıҪSetTextColorʹã + void SetTextColor(COLORREF textColor); //ÿؼıɫ + CString GetString() const; //ȡؼı + void SetURL(CString strURL); //ó + CString GetURL() const; //ȡַ + +protected: + COLORREF m_TextColor; //ؼɫ + CString m_text; //ؼϵı + + bool m_isHyperLink{ false }; //ҪؼΪӣΪtrue + bool m_bHot{ false }; //ָʱΪtrue + CString m_strURL; //ַ + + virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); +public: + DECLARE_MESSAGE_MAP() + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnPaint(); + afx_msg void OnMouseHover(UINT nFlags, CPoint point); + afx_msg void OnMouseLeave(); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + virtual void PreSubclassWindow(); +}; + diff --git a/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.cpp b/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.cpp new file mode 100644 index 0000000..370575e --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.cpp @@ -0,0 +1,450 @@ +// TaskBarDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "TaskBarDlg.h" +#include "afxdialogex.h" + + +// CTaskBarDlg Ի + +IMPLEMENT_DYNAMIC(CTaskBarDlg, CDialogEx) + +CTaskBarDlg::CTaskBarDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_TASK_BAR_DIALOG, pParent) +{ + +} + +CTaskBarDlg::~CTaskBarDlg() +{ +} + +void CTaskBarDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CTaskBarDlg, CDialogEx) + ON_WM_RBUTTONUP() + ON_WM_INITMENU() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDBLCLK() +END_MESSAGE_MAP() + + +// CTaskBarDlg Ϣ + + +void CTaskBarDlg::ShowInfo() +{ + if (this->m_hWnd == NULL || m_pDC == nullptr) return; + CString str; + CString in_speed = CCommon::DataSizeToString(theApp.m_in_speed); + CString out_speed = CCommon::DataSizeToString(theApp.m_out_speed); + + //ûDC + CDC MemDC; + CBitmap MemBitmap; + MemDC.CreateCompatibleDC(NULL); + int draw_width = (theApp.m_tbar_show_cpu_memory ? m_window_width : m_window_width_s); + MemBitmap.CreateCompatibleBitmap(m_pDC, draw_width, m_rect.Height()); + MemDC.SelectObject(&MemBitmap); + //ͼ + CRect tmp{ m_rect }; + tmp.MoveToXY(0, 0); + MemDC.FillSolidRect(tmp, theApp.m_tbar_back_color); //䱳ɫ + MemDC.SelectObject(&m_font); + //ϴٶ + tmp.bottom = m_window_height / 2; + tmp.right = tmp.left + m_window_width_s; + if (!theApp.m_tbar_swap_up_down) + str.Format(_T("%s%s/s"), theApp.m_tbar_up_string.c_str(), out_speed.GetString()); + else + str.Format(_T("%s%s/s"), theApp.m_tbar_down_string.c_str(), in_speed.GetString()); + CCommon::DrawWindowText(&MemDC, tmp, str, theApp.m_tbar_text_color, theApp.m_tbar_back_color); + //ٶ + tmp.MoveToY(tmp.bottom); + if (!theApp.m_tbar_swap_up_down) + str.Format(_T("%s%s/s"), theApp.m_tbar_down_string.c_str(), in_speed.GetString()); + else + str.Format(_T("%s%s/s"), theApp.m_tbar_up_string.c_str(), out_speed.GetString()); + CCommon::DrawWindowText(&MemDC, tmp, str, theApp.m_tbar_text_color, theApp.m_tbar_back_color); + if (theApp.m_tbar_show_cpu_memory) + { + //CPU + if (m_taskbar_on_top_or_bottom) + { + tmp.MoveToXY(m_window_width_s, 0); + tmp.right = tmp.left + (m_window_width - m_window_width_s); + } + else + { + tmp.MoveToY(m_window_height); + tmp.right = tmp.left + (m_window_width - m_window_width_s); + } + str.Format(_T("%s%d%%"), theApp.m_tbar_cpu_string.c_str(), theApp.m_cpu_usage); + CCommon::DrawWindowText(&MemDC, tmp, str, theApp.m_tbar_text_color, theApp.m_tbar_back_color); + //ڴ + tmp.MoveToY(tmp.bottom); + str.Format(_T("%s%d%%"), theApp.m_tbar_memory_string.c_str(), theApp.m_memory_usage); + CCommon::DrawWindowText(&MemDC, tmp, str, theApp.m_tbar_text_color, theApp.m_tbar_back_color); + } + //DCеͼ񿽱Ļʾ + m_pDC->BitBlt(0,0, draw_width, m_rect.Height(), &MemDC, 0, 0, SRCCOPY); + MemBitmap.DeleteObject(); + MemDC.DeleteDC(); +} + + +bool CTaskBarDlg::AdjustWindowPos() +{ + if (this->m_hWnd == NULL) + return false; + CRect rcMin; + ::GetWindowRect(m_hMin, rcMin); //Сڵ + m_taskbar_on_top_or_bottom = IsTaskbarOnTopOrBottom(); + if (m_taskbar_on_top_or_bottom) //涥ײʱ + { + //ôڴС + m_rect.right = m_rect.left + (theApp.m_tbar_show_cpu_memory ? m_window_width : m_window_width_s); + m_rect.bottom = m_rect.top + m_window_height; + if (rcMin.Width() != m_min_bar_width) //СڵĿȸıˣڵλ + { + m_rcMin = rcMin; + m_min_bar_width = m_rcMin.Width() - m_rect.Width(); //Сڿ + ::MoveWindow(m_hMin, 0, 0, m_rcMin.Width() - m_rect.Width(), m_rcMin.Height(), TRUE); //Сڵλ + ::MoveWindow(this->m_hWnd, m_rcMin.Width() - m_rect.Width() + 2, (m_rcMin.Height() - m_rect.Height()) / 2, \ + m_rect.Width(), m_rect.Height(), TRUE); //ڵλ + + CRect rect; + GetWindowRect(rect); //ȡǰڵľλ + //ûбɹǶ뵽ƶ˻ĻϽǵľλãڵλ + if (rect.left == m_rcMin.Width() - m_rect.Width() + 2 && rect.top == (m_rcMin.Height() - m_rect.Height()) / 2) + { + rect.MoveToXY(rect.left + m_rcBar.left, rect.top + m_rcBar.top); + this->MoveWindow(rect); + } + } + } + else //ĻҲʱ + { + //ôڴС + m_rect.right = m_rect.left + m_window_width_s; + m_rect.bottom = m_rect.top + (theApp.m_tbar_show_cpu_memory ? (2 * m_window_height) : m_window_height); + if (rcMin.Height() != m_min_bar_height) //Сڵĸ߶ȸıˣڵλ + { + m_rcMin = rcMin; + m_min_bar_height = m_rcMin.Height() - m_rect.Height(); //Сڸ߶ + ::MoveWindow(m_hMin, 0, 0, m_rcMin.Width(), m_rcMin.Height() - m_rect.Height(), TRUE); //Сڵλ + int left_pos = (m_rcMin.Width() - m_window_width_s) / 2; + if (left_pos < 0) left_pos = 0; + ::MoveWindow(this->m_hWnd, left_pos, m_rcMin.Height() - m_rect.Height() + 2, \ + m_rect.Width(), m_rect.Height(), TRUE); //ڵλ + + CRect rect; + GetWindowRect(rect); //ȡǰڵľλ + //ûбɹǶ뵽ƶ˻ĻϽǵľλãڵλ + if (rect.left == left_pos && rect.top == m_rcMin.Height() - m_rect.Height() + 2) + { + rect.MoveToXY(rect.left + m_rcBar.left, rect.top + m_rcBar.top); + this->MoveWindow(rect); + } + } + } + if (m_connot_insert_to_task_bar && ::GetForegroundWindow() == m_hTaskbar) //ڴ޷Ƕʱϣôö + { + SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ö + } + return true; +} + + +bool CTaskBarDlg::IsTaskbarOnTopOrBottom() +{ + CRect rect; + if (m_hTaskbar != 0) + { + ::GetWindowRect(m_hTaskbar, rect); //ȡľ + return (rect.Width()>=rect.Height()); //Ŀȴڸ߶ȣĻĶײ + } + else + { + return true; + } +} + +void CTaskBarDlg::SaveConfig() +{ + CCommon::WritePrivateProfileIntW(L"task_bar", L"task_bar_back_color", theApp.m_tbar_back_color, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"task_bar", L"task_bar_text_color", theApp.m_tbar_text_color, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"task_bar", L"tack_bar_show_cpu_memory", theApp.m_tbar_show_cpu_memory, theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("task_bar"), _T("tack_bar_font_name"), theApp.m_tbar_font_name, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"task_bar", L"tack_bar_font_size", theApp.m_tbar_font_size, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"task_bar", L"task_bar_swap_up_down", theApp.m_tbar_swap_up_down, theApp.m_config_path.c_str()); + + WritePrivateProfileString(_T("task_bar"), _T("up_string"), (theApp.m_tbar_up_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("task_bar"), _T("down_string"), (theApp.m_tbar_down_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("task_bar"), _T("cpu_string"), (theApp.m_tbar_cpu_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("task_bar"), _T("memory_string"), (theApp.m_tbar_memory_string + L'$').c_str(), theApp.m_config_path.c_str()); +} + +void CTaskBarDlg::LoadConfig() +{ + theApp.m_tbar_back_color = GetPrivateProfileInt(_T("task_bar"), _T("task_bar_back_color"), 0, theApp.m_config_path.c_str()); + theApp.m_tbar_text_color = GetPrivateProfileInt(_T("task_bar"), _T("task_bar_text_color"), 0x00ffffffU, theApp.m_config_path.c_str()); + theApp.m_tbar_show_cpu_memory = (GetPrivateProfileInt(_T("task_bar"), _T("tack_bar_show_cpu_memory"), 1, theApp.m_config_path.c_str()) != 0); + theApp.m_tbar_swap_up_down = (GetPrivateProfileInt(_T("task_bar"), _T("task_bar_swap_up_down"), 0, theApp.m_config_path.c_str()) != 0); + GetPrivateProfileString(_T("task_bar"), _T("tack_bar_font_name"), _T("΢ź"), theApp.m_tbar_font_name.GetBuffer(32), 32, theApp.m_config_path.c_str()); + theApp.m_tbar_font_size = GetPrivateProfileInt(_T("task_bar"), _T("tack_bar_font_size"), 9, theApp.m_config_path.c_str()); + + wchar_t buff[256]; + GetPrivateProfileStringW(L"task_bar", L"up_string", L":", buff, 256, theApp.m_config_path.c_str()); + theApp.m_tbar_up_string = buff; + if (!theApp.m_tbar_up_string.empty() && theApp.m_tbar_up_string.back() == L'$') //ȡַĩβ'$'ɾڽȡiniļַʱ޷ӮȡĩβĿո⣬ʱֻҪĩβ'$' + theApp.m_tbar_up_string.pop_back(); + GetPrivateProfileStringW(L"task_bar", L"down_string", L":", buff, 256, theApp.m_config_path.c_str()); + theApp.m_tbar_down_string = buff; + if (!theApp.m_tbar_down_string.empty() && theApp.m_tbar_down_string.back() == L'$') + theApp.m_tbar_down_string.pop_back(); + GetPrivateProfileStringW(L"task_bar", L"cpu_string", L"CPU:", buff, 256, theApp.m_config_path.c_str()); + theApp.m_tbar_cpu_string = buff; + if (!theApp.m_tbar_cpu_string.empty() && theApp.m_tbar_cpu_string.back() == L'$') + theApp.m_tbar_cpu_string.pop_back(); + GetPrivateProfileStringW(L"task_bar", L"memory_string", L"ڴ:", buff, 256, theApp.m_config_path.c_str()); + theApp.m_tbar_memory_string = buff; + if (!theApp.m_tbar_memory_string.empty() && theApp.m_tbar_memory_string.back() == L'$') + theApp.m_tbar_memory_string.pop_back(); +} + +void CTaskBarDlg::ApplySettings() +{ + //m_fontѾһԴͷ + if (m_font.m_hObject) + { + m_font.DeleteObject(); + } + //µ + m_font.CreatePointFont(theApp.m_tbar_font_size * 10, theApp.m_tbar_font_name); + + CalculateWindowWidth(); +} + +void CTaskBarDlg::CalculateWindowWidth() +{ + //ʾϴزҪĿ + CString str1, str2; + int width1, width2; + str1.Format(_T("%s8888.8KB/s"), theApp.m_tbar_up_string.c_str()); + str2.Format(_T("%s8888.8KB/s"), theApp.m_tbar_down_string.c_str()); + width1= m_pDC->GetTextExtent(str1).cx; //ʹõǰʾıҪĿֵ + width2= m_pDC->GetTextExtent(str2).cx; + m_window_width_s = max(width1, width2); + + //ʾCPUڴ沿ҪĿ + int width_cpu_memory; + str1.Format(_T("%s100%%"), theApp.m_tbar_cpu_string.c_str()); + str2.Format(_T("%s100%%"), theApp.m_tbar_memory_string.c_str()); + width1 = m_pDC->GetTextExtent(str1).cx; + width2 = m_pDC->GetTextExtent(str2).cx; + width_cpu_memory = max(width1, width2); + m_window_width = m_window_width_s + width_cpu_memory; +} + +void CTaskBarDlg::SetToolTipsTopMost() +{ + m_tool_tips.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); +} + +BOOL CTaskBarDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: ڴӶijʼ + //ͼ + ModifyStyleEx(0, WS_EX_TOOLWINDOW); + + LoadConfig(); + + m_pDC = GetDC(); + + // + m_font.CreatePointFont(theApp.m_tbar_font_size * 10, theApp.m_tbar_font_name); + m_pDC->SelectObject(&m_font); + + this->GetWindowRect(m_rect); + //m_window_width = m_rect.Width(); + //m_window_width_s = static_cast(m_rect.Width()*0.566f + 0.5f); + CalculateWindowWidth(); + m_window_height = m_rect.Height(); + if (!theApp.m_tbar_show_cpu_memory) + m_rect.right = m_rect.left + m_window_width_s; + else + m_rect.right = m_rect.left + m_window_width; + + m_hTaskbar = ::FindWindow(L"Shell_TrayWnd", NULL); //ѰShell_TrayWndĴھ + m_hBar = ::FindWindowEx(m_hTaskbar, 0, L"ReBarWindow32", NULL); //ѰҶľ + m_hMin = ::FindWindowEx(m_hBar, 0, L"MSTaskSwWClass", NULL); //ѰСڵľ + + ::GetWindowRect(m_hMin, m_rcMin); //Сڵ + ::GetWindowRect(m_hBar, m_rcBar); //ö + + m_taskbar_on_top_or_bottom = IsTaskbarOnTopOrBottom(); + if (m_taskbar_on_top_or_bottom) //涥ײ + { + m_min_bar_width = m_rcMin.Width() - m_rect.Width(); //Сڿ + + //ͨMoveWindowıСڵĿ + ::MoveWindow(m_hMin, 0, 0, m_rcMin.Width() - m_rect.Width(), m_rcMin.Height(), TRUE); + + ::SetParent(this->m_hWnd, m_hBar); //ѳ򴰿óӴ + + //򴰿ڵĴСλ + //עѵǰΪӴںMoveWindowƶλǻλã + //ijЩ£类ȫֹʱ޷ǶڻƶĻϽǵľλá + ::MoveWindow(this->m_hWnd, m_rcMin.Width() - m_rect.Width() + 2, (m_rcBar.Height() - m_rect.Height()) / 2, \ + m_rect.Width(), m_rect.Height(), TRUE); + + CRect rect; + GetWindowRect(rect); //ȡǰڵľλ + //ûбɹǶ뵽ƶ˻ĻϽǵľλãڵλ + if (rect.left == m_rcMin.Width() - m_rect.Width() + 2 && rect.top == (m_rcBar.Height() - m_rect.Height()) / 2) + { + rect.MoveToXY(rect.left + m_rcBar.left, rect.top + m_rcBar.top); + this->MoveWindow(rect); + m_connot_insert_to_task_bar = true; + MessageBox(_T("棺ûгɹǶѱȫֹ"), NULL, MB_ICONWARNING); + } + } + else //Ҳʱ + { + int left_pos = (m_rcMin.Width() - m_window_width_s) / 2; + if (left_pos < 0) left_pos = 0; + if (theApp.m_tbar_show_cpu_memory) //CPUڴʷŵٵ + { + m_rect.right = m_rect.left + m_window_width_s; + m_rect.bottom = m_rect.top + m_rect.Height() * 2; + } + m_min_bar_height = m_rcMin.Height() - m_rect.Height(); //Сڸ߶ + + //ͨMoveWindowıСڵĸ߶ + ::MoveWindow(m_hMin, 0, 0, m_rcMin.Width(), m_rcMin.Height() - m_rect.Height(), TRUE); + + ::SetParent(this->m_hWnd, m_hBar); //ѳ򴰿óӴ + + //򴰿ڵĴСλ + //עѵǰΪӴںMoveWindowƶλǻλã + //ijЩ£类ȫֹʱ޷ǶڻƶĻϽǵľλá + ::MoveWindow(this->m_hWnd, left_pos, m_rcMin.Height() - m_rect.Height() + 2, \ + m_rect.Width(), m_rect.Height(), TRUE); + + CRect rect; + GetWindowRect(rect); //ȡǰڵľλ + //ûбɹǶ뵽ƶ˻ĻϽǵľλãڵλ + if (rect.left == left_pos && rect.top == m_rcMin.Height() - m_rect.Height() + 2) + { + rect.MoveToXY(rect.left + m_rcBar.left, rect.top + m_rcBar.top); + this->MoveWindow(rect); + m_connot_insert_to_task_bar = true; + MessageBox(_T("棺ûгɹǶѱȫֹ"), NULL, MB_ICONWARNING); + } + } + + m_menu.LoadMenu(IDR_TASK_BAR_MENU); + + SetBackgroundColor(theApp.m_tbar_back_color); + + m_tool_tips.Create(this, TTS_ALWAYSTIP); + SetToolTipsTopMost(); //ʾϢö + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void CTaskBarDlg::OnCancel() +{ + // TODO: ڴרô/û + SaveConfig(); + DestroyWindow(); + //رյʱ򣬰Сڵwidthָȥ + ::MoveWindow(m_hMin, 0, 0, m_rcMin.Width(), m_rcMin.Height(), TRUE); + + //CDialogEx::OnCancel(); +} + + +void CTaskBarDlg::OnRButtonUp(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + + CPoint point1; //һȷλõλ + GetCursorPos(&point1); //ȡǰλãԱʹò˵Ը + m_menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point1.x, point1.y, this); //ָλʾ˵ + CDialogEx::OnRButtonUp(nFlags, point1); +} + + +void CTaskBarDlg::OnInitMenu(CMenu* pMenu) +{ + CDialogEx::OnInitMenu(pMenu); + + // TODO: ڴ˴Ϣ + pMenu->CheckMenuItem(ID_SHOW_CPU_MEMORY2, MF_BYCOMMAND | (theApp.m_tbar_show_cpu_memory ? MF_CHECKED : MF_UNCHECKED)); + pMenu->CheckMenuItem(ID_HIDE_MAIN_WND, MF_BYCOMMAND | (theApp.m_hide_main_window ? MF_CHECKED : MF_UNCHECKED)); + pMenu->CheckMenuItem(ID_SHOW_NOTIFY_ICON, MF_BYCOMMAND | (theApp.m_show_notify_icon ? MF_CHECKED : MF_UNCHECKED)); + + pMenu->SetDefaultItem(ID_NETWORK_INFO); +} + + +BOOL CTaskBarDlg::PreTranslateMessage(MSG* pMsg) +{ + // TODO: ڴרô/û + //ΰسESC˳ + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) return TRUE; + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) return TRUE; + + if (m_tool_tips.GetSafeHwnd() && (pMsg->message == WM_LBUTTONDOWN || + pMsg->message == WM_LBUTTONUP || + pMsg->message == WM_MOUSEMOVE)) + { + m_tool_tips.RelayEvent(pMsg); + } + + return CDialogEx::PreTranslateMessage(pMsg); +} + + +void CTaskBarDlg::OnMouseMove(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + m_tool_tips.SetMaxTipWidth(600); + CString tip_info; + if (theApp.m_tbar_show_cpu_memory) + { + tip_info.Format(_T("ʹ%s\r\nڴʹã%s/%s"), CCommon::KBytesToString(static_cast(theApp.m_today_traffic / 1024)), + CCommon::KBytesToString(theApp.m_used_memory), CCommon::KBytesToString(theApp.m_total_memory)); + } + else + { + tip_info.Format(_T("ʹ%s\r\nCPUʹã%d%%\r\nڴʹã%s/%s (%d%%)"), CCommon::KBytesToString(static_cast(theApp.m_today_traffic / 1024)), + theApp.m_cpu_usage, + CCommon::KBytesToString(theApp.m_used_memory), CCommon::KBytesToString(theApp.m_total_memory), + theApp.m_memory_usage); + } + m_tool_tips.AddTool(this, tip_info); + //m_tool_tips.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ʾϢö + + CDialogEx::OnMouseMove(nFlags, point); +} + + +void CTaskBarDlg::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + SendMessage(WM_COMMAND,ID_NETWORK_INFO); //˫󵯳顱Ի + CDialogEx::OnLButtonDblClk(nFlags, point); +} diff --git a/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.h b/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.h new file mode 100644 index 0000000..345a5dc --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TaskBarDlg.h @@ -0,0 +1,87 @@ +#pragma once +#include "Common.h" +#include "afxwin.h" +//#include "StaticEx.h" + +// CTaskBarDlg Ի + +class CTaskBarDlg : public CDialogEx +{ + DECLARE_DYNAMIC(CTaskBarDlg) + +public: + CTaskBarDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CTaskBarDlg(); + + CToolTipCtrl m_tool_tips; + + + //ʾ4Ŀǰַ + //wstring m_up_string; //ĬΪ: + //wstring m_down_string; //ĬΪ: + //wstring m_cpu_string; //ĬΪCPU: + //wstring m_memory_string; //ĬΪڴ: + + void ShowInfo(); //Ϣʾؼ + bool AdjustWindowPos(); //ôеλ + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_TASK_BAR_DIALOG }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + HWND m_hTaskbar; //ھ + HWND m_hBar; //ڶľ + HWND m_hMin; //Сڵľ + CRect m_rcBar; //ڵľ + CRect m_rcMin; //Сڵľ + CRect m_rect; //ǰڵľ + int m_window_width; //ڿ + int m_window_width_s; //ʾCPUڴʱĴڿ + int m_window_height; + + int m_min_bar_width; //ССȺĿ + int m_min_bar_height; //СС߶Ⱥĸ߶ȣĻҲʱ + + bool m_connot_insert_to_task_bar{ false }; //޷ǶΪtrue + bool m_taskbar_on_top_or_bottom{ true }; //ĻײΪture + + CMenu m_menu; //Ҽ˵ + + //COLORREF m_back_color{ RGB(0,0,0) }; //ɫ + //COLORREF m_text_color{ RGB(255,255,255) }; //ɫ + CFont m_font; // + //CString m_font_name; // + //int m_font_size; //С + + //bool m_swap_up_down{ false }; //ϴʾλ + + CDC* m_pDC{}; + + bool IsTaskbarOnTopOrBottom(); //жǷĻĶײ򷵻falseĻ࣬򷵻false + +public: + static void SaveConfig(); //õiniļ + static void LoadConfig(); //iniļ + + void ApplySettings(); + void CalculateWindowWidth(); //㴰ҪĿ + + void SetToolTipsTopMost(); //ʾö + DECLARE_MESSAGE_MAP() + +public: + virtual BOOL OnInitDialog(); + virtual void OnCancel(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + //afx_msg void OnSetBackgroundColor(); + //afx_msg void OnSetTextColor(); + afx_msg void OnInitMenu(CMenu* pMenu); + virtual BOOL PreTranslateMessage(MSG* pMsg); + //afx_msg void OnSetFont(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.cpp b/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.cpp new file mode 100644 index 0000000..8f55a72 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.cpp @@ -0,0 +1,203 @@ +// TaskBarSettingsDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "TaskBarSettingsDlg.h" +#include "afxdialogex.h" + + +// CTaskBarSettingsDlg Ի + +IMPLEMENT_DYNAMIC(CTaskBarSettingsDlg, CDialogEx) + +CTaskBarSettingsDlg::CTaskBarSettingsDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_TASKBAR_SETTINGS_DIALOG, pParent) +{ + +} + +CTaskBarSettingsDlg::~CTaskBarSettingsDlg() +{ +} + +void CTaskBarSettingsDlg::DrawStaticColor() +{ + CCommon::FillStaticColor(m_text_color_static, m_text_color); + CCommon::FillStaticColor(m_back_color_static, m_back_color); +} + +void CTaskBarSettingsDlg::DoDataExchange(CDataExchange* pDX) +{ + DDX_Control(pDX, IDC_TEXT_COLOR_STATIC1, m_text_color_static); + DDX_Control(pDX, IDC_TEXT_COLOR_STATIC2, m_back_color_static); + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CTaskBarSettingsDlg, CDialogEx) + ON_BN_CLICKED(IDC_SET_FONT_BUTTON1, &CTaskBarSettingsDlg::OnBnClickedSetFontButton1) + ON_BN_CLICKED(IDC_SET_COLOR_BUTTON2, &CTaskBarSettingsDlg::OnBnClickedSetColorButton2) + ON_BN_CLICKED(IDC_SET_COLOR_BUTTON3, &CTaskBarSettingsDlg::OnBnClickedSetColorButton3) + ON_EN_CHANGE(IDC_UPLOAD_EDIT1, &CTaskBarSettingsDlg::OnEnChangeUploadEdit1) + ON_EN_CHANGE(IDC_DOWNLOAD_EDIT1, &CTaskBarSettingsDlg::OnEnChangeDownloadEdit1) + ON_EN_CHANGE(IDC_CPU_EDIT1, &CTaskBarSettingsDlg::OnEnChangeCpuEdit1) + ON_EN_CHANGE(IDC_MEMORY_EDIT1, &CTaskBarSettingsDlg::OnEnChangeMemoryEdit1) + ON_BN_CLICKED(IDC_SET_DEFAULT_BUTTON1, &CTaskBarSettingsDlg::OnBnClickedSetDefaultButton1) + ON_BN_CLICKED(IDC_SWITCH_UP_DOWN_CHECK1, &CTaskBarSettingsDlg::OnBnClickedSwitchUpDownCheck1) +END_MESSAGE_MAP() + + +// CTaskBarSettingsDlg Ϣ + + +BOOL CTaskBarSettingsDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // TODO: ڴӶijʼ + SetBackgroundColor(RGB(255, 255, 255)); + + //ʼؼ״̬ + SetDlgItemText(IDC_FONT_NAME_EDIT1, m_font_name); + wchar_t buff[16]; + swprintf_s(buff, L"%d", m_font_size); + SetDlgItemText(IDC_FONT_SIZE_EDIT1, buff); + + SetDlgItemText(IDC_UPLOAD_EDIT1, m_up_string.c_str()); + SetDlgItemText(IDC_DOWNLOAD_EDIT1, m_down_string.c_str()); + SetDlgItemText(IDC_CPU_EDIT1, m_cpu_string.c_str()); + SetDlgItemText(IDC_MEMORY_EDIT1, m_memory_string.c_str()); + + ((CButton*)GetDlgItem(IDC_SWITCH_UP_DOWN_CHECK1))->SetCheck(m_swap_up_down); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + +void CTaskBarSettingsDlg::OnBnClickedSetFontButton1() +{ + // TODO: ڴӿؼ֪ͨ + CFont font; + font.CreatePointFont(m_font_size * 10, m_font_name); + LOGFONT lf{}; //LOGFONT + font.GetLogFont(&lf); + CFontDialog fontDlg(&lf); //Ի򣬳ʼѡΪ֮ǰ + if (IDOK == fontDlg.DoModal()) // ʾԻ + { + //ȡϢ + m_font_name = fontDlg.GetFaceName(); + m_font_size = fontDlg.GetSize() / 10; + //Ϣʾ + SetDlgItemText(IDC_FONT_NAME_EDIT1, m_font_name); + wchar_t buff[16]; + swprintf_s(buff, L"%d", m_font_size); + SetDlgItemText(IDC_FONT_SIZE_EDIT1, buff); + } +} + +//ıɫ +void CTaskBarSettingsDlg::OnBnClickedSetColorButton2() +{ + // TODO: ڴӿؼ֪ͨ + CColorDialog colorDlg(m_text_color, 0, this); + if (colorDlg.DoModal() == IDOK) + { + m_text_color = colorDlg.GetColor(); + if (m_back_color == m_text_color) + MessageBox(_T("棺ɫͱɫͬ"), NULL, MB_ICONWARNING); + DrawStaticColor(); + } +} + +//ñɫ +void CTaskBarSettingsDlg::OnBnClickedSetColorButton3() +{ + // TODO: ڴӿؼ֪ͨ + CColorDialog colorDlg(m_back_color, 0, this); + if (colorDlg.DoModal() == IDOK) + { + m_back_color = colorDlg.GetColor(); + if (m_back_color == m_text_color) + MessageBox(_T("棺ɫɫͬ"), NULL, MB_ICONWARNING); + DrawStaticColor(); + } +} + + +void CTaskBarSettingsDlg::OnEnChangeUploadEdit1() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_UPLOAD_EDIT1, tmp); + m_up_string = tmp; +} + + +void CTaskBarSettingsDlg::OnEnChangeDownloadEdit1() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_DOWNLOAD_EDIT1, tmp); + m_down_string = tmp; +} + + +void CTaskBarSettingsDlg::OnEnChangeCpuEdit1() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_CPU_EDIT1, tmp); + m_cpu_string = tmp; +} + + +void CTaskBarSettingsDlg::OnEnChangeMemoryEdit1() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ʹ֪ͨд CDialogEx::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + CString tmp; + GetDlgItemText(IDC_MEMORY_EDIT1, tmp); + m_memory_string = tmp; +} + + +void CTaskBarSettingsDlg::OnBnClickedSetDefaultButton1() +{ + // TODO: ڴӿؼ֪ͨ + m_up_string = L":"; + m_down_string = L":"; + m_cpu_string = L"CPU:"; + m_memory_string = L"ڴ:"; + SetDlgItemText(IDC_UPLOAD_EDIT1, m_up_string.c_str()); + SetDlgItemText(IDC_DOWNLOAD_EDIT1, m_down_string.c_str()); + SetDlgItemText(IDC_CPU_EDIT1, m_cpu_string.c_str()); + SetDlgItemText(IDC_MEMORY_EDIT1, m_memory_string.c_str()); +} + + +void CTaskBarSettingsDlg::OnBnClickedSwitchUpDownCheck1() +{ + // TODO: ڴӿؼ֪ͨ + m_swap_up_down = (((CButton*)GetDlgItem(IDC_SWITCH_UP_DOWN_CHECK1))->GetCheck() != 0); +} diff --git a/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.h b/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.h new file mode 100644 index 0000000..fa066e8 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TaskBarSettingsDlg.h @@ -0,0 +1,50 @@ +#pragma once + + +// CTaskBarSettingsDlg Ի + +class CTaskBarSettingsDlg : public CDialogEx +{ + DECLARE_DYNAMIC(CTaskBarSettingsDlg) + +public: + CTaskBarSettingsDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CTaskBarSettingsDlg(); + + //ѡ + CString m_font_name; + int m_font_size; + COLORREF m_text_color; + COLORREF m_back_color; + wstring m_up_string; //ĬΪϴ: + wstring m_down_string; //ĬΪ: + wstring m_cpu_string; //ĬΪCPU: + wstring m_memory_string; //ĬΪڴ: + bool m_swap_up_down; //Ƿ񽻻ϴصλ + + void DrawStaticColor(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_TASKBAR_SETTINGS_DIALOG }; +#endif + +protected: + CStatic m_text_color_static; + CStatic m_back_color_static; + + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedSetFontButton1(); + afx_msg void OnBnClickedSetColorButton2(); + afx_msg void OnBnClickedSetColorButton3(); + afx_msg void OnEnChangeUploadEdit1(); + afx_msg void OnEnChangeDownloadEdit1(); + afx_msg void OnEnChangeCpuEdit1(); + afx_msg void OnEnChangeMemoryEdit1(); + afx_msg void OnBnClickedSetDefaultButton1(); + afx_msg void OnBnClickedSwitchUpDownCheck1(); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.aps b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.aps new file mode 100644 index 0000000..6bcef75 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.aps differ diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.cpp b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.cpp new file mode 100644 index 0000000..07c10fa --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.cpp @@ -0,0 +1,181 @@ + +// TrafficMonitor.cpp : ӦóΪ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "TrafficMonitorDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CTrafficMonitorApp + +BEGIN_MESSAGE_MAP(CTrafficMonitorApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CTrafficMonitorApp + +CTrafficMonitorApp::CTrafficMonitorApp() +{ + // ֧ + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: ڴ˴ӹ룬 + // Ҫijʼ InitInstance +} + +//void CTrafficMonitorApp::_OnOptions(int tab) +//{ +// COptionsDlg optionsDlg(tab); +// //ѡݴݸѡöԻ +// optionsDlg.m_tab1_dlg.m_font_name = theApp.m_font_name; +// optionsDlg.m_tab1_dlg.m_font_size = theApp.m_font_size; +// optionsDlg.m_tab1_dlg.m_text_color = theApp.m_text_color; +// optionsDlg.m_tab1_dlg.m_up_string = theApp.m_up_string; +// optionsDlg.m_tab1_dlg.m_down_string = theApp.m_down_string; +// optionsDlg.m_tab1_dlg.m_cpu_string = theApp.m_cpu_string; +// optionsDlg.m_tab1_dlg.m_memory_string = theApp.m_memory_string; +// optionsDlg.m_tab1_dlg.m_swap_up_down = theApp.m_swap_up_down; +// +// optionsDlg.m_tab2_dlg.m_font_name = theApp.m_tbar_font_name; +// optionsDlg.m_tab2_dlg.m_font_size = theApp.m_tbar_font_size; +// optionsDlg.m_tab2_dlg.m_text_color = theApp.m_tbar_text_color; +// optionsDlg.m_tab2_dlg.m_back_color = theApp.m_tbar_back_color; +// optionsDlg.m_tab2_dlg.m_up_string = theApp.m_tbar_up_string; +// optionsDlg.m_tab2_dlg.m_down_string = theApp.m_tbar_down_string; +// optionsDlg.m_tab2_dlg.m_cpu_string = theApp.m_tbar_cpu_string; +// optionsDlg.m_tab2_dlg.m_memory_string = theApp.m_tbar_memory_string; +// optionsDlg.m_tab2_dlg.m_swap_up_down = theApp.m_tbar_swap_up_down; +// +// if (optionsDlg.DoModal() == IDOK) +// { +// theApp.m_font_name = optionsDlg.m_tab1_dlg.m_font_name; +// theApp.m_font_size = optionsDlg.m_tab1_dlg.m_font_size; +// theApp.m_text_color = optionsDlg.m_tab1_dlg.m_text_color; +// theApp.m_up_string = optionsDlg.m_tab1_dlg.m_up_string; +// theApp.m_down_string = optionsDlg.m_tab1_dlg.m_down_string; +// theApp.m_cpu_string = optionsDlg.m_tab1_dlg.m_cpu_string; +// theApp.m_memory_string = optionsDlg.m_tab1_dlg.m_memory_string; +// theApp.m_swap_up_down = optionsDlg.m_tab1_dlg.m_swap_up_down; +// +// theApp.m_tbar_font_name = optionsDlg.m_tab2_dlg.m_font_name; +// theApp.m_tbar_font_size = optionsDlg.m_tab2_dlg.m_font_size; +// theApp.m_tbar_text_color = optionsDlg.m_tab2_dlg.m_text_color; +// theApp.m_tbar_back_color = optionsDlg.m_tab2_dlg.m_back_color; +// theApp.m_tbar_up_string = optionsDlg.m_tab2_dlg.m_up_string; +// theApp.m_tbar_down_string = optionsDlg.m_tab2_dlg.m_down_string; +// theApp.m_tbar_cpu_string = optionsDlg.m_tab2_dlg.m_cpu_string; +// theApp.m_tbar_memory_string = optionsDlg.m_tab2_dlg.m_memory_string; +// theApp.m_tbar_swap_up_down = optionsDlg.m_tab2_dlg.m_swap_up_down; +// } +//} + + +// Ψһһ CTrafficMonitorApp + +CTrafficMonitorApp theApp; + + +// CTrafficMonitorApp ʼ + +BOOL CTrafficMonitorApp::InitInstance() +{ +#ifndef _DEBUG + wstring cmd_line{ m_lpCmdLine }; + bool is_restart{ cmd_line.find(L"RestartByRestartManager") != wstring::npos }; //вкַRestartByRestartManager˵DZWindows + if (is_restart && CCommon::WhenStart()) //ڿʱֱ˳ + { + //AfxMessageBox(_T("ϢѱWindows")); + return FALSE; + } + + //Ƿʵ + HANDLE hMutex = ::CreateMutex(NULL, TRUE, _T("FirstName")); + if (hMutex != NULL) + { + if (GetLastError() == ERROR_ALREADY_EXISTS) + { + if (!is_restart) + AfxMessageBox(_T("ѾһС")); + return FALSE; + } + } +#endif + + //ļ· + wstring exe_path{ CCommon::GetExePath() }; + m_config_path = exe_path + L"config.ini"; + m_history_traffic_path = exe_path + L"history_traffic.dat"; + m_log_path = exe_path + L"error.log"; + m_skin_path = exe_path + L"skins"; + + // һ Windows XP ϵӦó嵥ָҪ + // ʹ ComCtl32.dll 汾 6 ߰汾ÿӻʽ + //Ҫ InitCommonControlsEx() 򣬽޷ڡ + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // ΪҪӦóʹõ + // ؼࡣ + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // shell ԷԻ + // κ shell ͼؼ shell бͼؼ + CShellManager *pShellManager = new CShellManager; + + // Windows NativeӾԱ MFC ؼ + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // ׼ʼ + // δʹЩܲϣС + // տִļĴСӦƳ + // Ҫضʼ + // ڴ洢õע + // TODO: Ӧʵ޸ĸַ + // ޸Ϊ˾֯ + SetRegistryKey(_T("ӦóɵıӦó")); + + CTrafficMonitorDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: ڴ˷ôʱ + // ȷرնԻĴ + } + else if (nResponse == IDCANCEL) + { + // TODO: ڴ˷ôʱ + // ȡرնԻĴ + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, ": Ի򴴽ʧܣӦóֹ\n"); + TRACE(traceAppMsg, 0, ": ڶԻʹ MFC ؼ޷ #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS\n"); + } + + // ɾ洴 shell + if (pShellManager != NULL) + { + delete pShellManager; + } + +#ifndef _AFXDLL + ControlBarCleanUp(); +#endif + + // ڶԻѹرգԽ FALSE Ա˳Ӧó + // ӦóϢá + return FALSE; +} + diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.h b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.h new file mode 100644 index 0000000..384f070 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.h @@ -0,0 +1,78 @@ + +// TrafficMonitor.h : PROJECT_NAME Ӧóͷļ +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "ڰļ֮ǰstdafx.h PCH ļ" +#endif + +#include "resource.h" // +#include "Common.h" + +// CTrafficMonitorApp: +// йشʵ֣ TrafficMonitor.cpp +// + +class CTrafficMonitorApp : public CWinApp +{ +public: + wstring m_config_path; + wstring m_history_traffic_path; + wstring m_log_path; + wstring m_skin_path; + + //ݶΪAppеĹԱԱԻжܷ + unsigned int m_in_speed{}; //ٶ + unsigned int m_out_speed{}; //ϴٶ + int m_cpu_usage{}; //CPU + int m_memory_usage{}; //ڴ + int m_used_memory{}; //ڴ棨λΪKB + int m_total_memory{}; //ڴλΪKB + + __int64 m_today_traffic{}; //ʹõ + + bool m_hide_main_window; // + bool m_show_notify_icon{ true }; //ʾ֪ͨͼ + + //ѡ + // + COLORREF m_text_color{}; //ɫ + CString m_font_name; // + int m_font_size; //С + wstring m_up_string; //ĬΪϴ: + wstring m_down_string; //ĬΪ: + wstring m_cpu_string; //ĬΪCPU: + wstring m_memory_string; //ĬΪڴ: + bool m_swap_up_down{ false }; //ϴʾλ + bool m_hide_main_wnd_when_fullscreen; //гȫʱ + + // + COLORREF m_tbar_back_color{ RGB(0,0,0) }; //ɫ + COLORREF m_tbar_text_color{ RGB(255,255,255) }; //ɫ + CString m_tbar_font_name; // + int m_tbar_font_size; //С + wstring m_tbar_up_string; //ĬΪ: + wstring m_tbar_down_string; //ĬΪ: + wstring m_tbar_cpu_string; //ĬΪCPU: + wstring m_tbar_memory_string; //ĬΪڴ: + bool m_tbar_swap_up_down{ false }; //ϴʾλ + + bool m_tbar_show_cpu_memory; //ʾCPUڴ + + CTrafficMonitorApp(); + + //򿪡ѡԻĴΪʱлıǩ + //void _OnOptions(int tab); + +// д +public: + virtual BOOL InitInstance(); + +// ʵ + + DECLARE_MESSAGE_MAP() +}; + +extern CTrafficMonitorApp theApp; \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.rc b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.rc new file mode 100644 index 0000000..b2365d7 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.rc differ diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj new file mode 100644 index 0000000..26b7328 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj @@ -0,0 +1,244 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {09483BED-B1E9-4827-8120-A18302C84AA8} + TrafficMonitor + 10.0.17763.0 + MFCProj + + + + Application + true + v141 + Unicode + Dynamic + + + Application + false + v141 + true + Unicode + Static + + + Application + true + v141 + Unicode + Dynamic + + + Application + false + v141 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + Disabled + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.filters b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.filters new file mode 100644 index 0000000..d8e2ef7 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.filters @@ -0,0 +1,138 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {ab02c896-0397-42e2-b413-ccc7e470ec13} + + + {296f91e9-59c8-4e1c-9281-b3a5aad240d8} + + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + 头文件\对话框类 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + 源文件\对话框类 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.user b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.user new file mode 100644 index 0000000..abe8dd8 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitor.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.cpp b/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.cpp new file mode 100644 index 0000000..a7a2511 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.cpp @@ -0,0 +1,1657 @@ + +// TrafficMonitorDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "TrafficMonitor.h" +#include "TrafficMonitorDlg.h" +#include "afxdialogex.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// Ӧó򡰹ڡ˵ CAboutDlg Ի + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + + // Ի + +protected: + CStatic m_about_img; //ڶԻеͼƬ + CStaticEx m_mail{ true }; //ϵߡ + CStaticEx m_check_update{ true }; //¡ + CStaticEx m_github{ true }; //GitHub + CStaticEx m_donate{ true }; // + CToolTipCtrl m_Mytip; //ָʱĹʾ + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + // ʵ +protected: + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + afx_msg void OnStnClickedStaticDonate(); +}; + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + ON_STN_CLICKED(IDC_STATIC_DONATE, &CAboutDlg::OnStnClickedStaticDonate) +END_MESSAGE_MAP() + +CAboutDlg::CAboutDlg() : CDialog(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_STATIC_ABOUT, m_about_img); + DDX_Control(pDX, IDC_STATIC_MAIL, m_mail); + DDX_Control(pDX, IDC_STATIC_CHECK_UPDATE, m_check_update); + DDX_Control(pDX, IDC_STATIC_GITHUB, m_github); + DDX_Control(pDX, IDC_STATIC_DONATE, m_donate); +} + +BOOL CAboutDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + CRect rect; + GetClientRect(rect); + rect.bottom = rect.Height() * 2 / 5; //ͼƬ߶ռԻ߶ȵ2/5 + m_about_img.MoveWindow(rect); + m_mail.SetURL(_T("mailto:zhongyang219@hotmail.com")); //ó + m_check_update.SetURL(_T("http://pan.baidu.com/s/1c1LkPQ4")); + m_github.SetURL(_T("https://github.com/zhongyang219/TrafficMonitor")); + + m_Mytip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX); + m_Mytip.AddTool(&m_mail, _T("߷͵ʼ\r\nmailto:zhongyang219@hotmail.com")); + m_Mytip.AddTool(&m_check_update, _T("ٶӲ鿴Ƿи\r\nhttp://pan.baidu.com/s/1c1LkPQ4")); + m_Mytip.AddTool(&m_github, _T("תĿGitHubϵҳ\r\nhttps://github.com/zhongyang219/TrafficMonitor")); + m_Mytip.AddTool(&m_donate, _T("")); + m_Mytip.SetDelayTime(300); //ӳ + m_Mytip.SetMaxTipWidth(800); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + +BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg) +{ + // TODO: ڴרô/û + if (pMsg->message == WM_MOUSEMOVE) + m_Mytip.RelayEvent(pMsg); + return CDialog::PreTranslateMessage(pMsg); +} + +void CAboutDlg::OnStnClickedStaticDonate() +{ + CDonateDlg donateDlg; + donateDlg.DoModal(); +} + +// CTrafficMonitorDlg Ի + +//̬Աʼ +unsigned int CTrafficMonitorDlg::m_WM_TASKBARCREATED{ ::RegisterWindowMessage(_T("TaskbarCreated")) }; //עϢ + +CTrafficMonitorDlg::CTrafficMonitorDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_TRAFFICMONITOR_DIALOG, pParent) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + LoadConfig(); //ʱiniļ + CTaskBarDlg::LoadConfig(); + GetScreenSize(); //ȡĻС +} + +CTrafficMonitorDlg::~CTrafficMonitorDlg() +{ + free(m_pIfTable); + + if (m_tBarDlg != nullptr) + { + delete m_tBarDlg; + m_tBarDlg = nullptr; + } +} + +void CTrafficMonitorDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_STATIC_UP, m_disp_up); + DDX_Control(pDX, IDC_STATIC_DOWN, m_disp_down); + DDX_Control(pDX, IDC_STATIC_CPU, m_disp_cpu); + DDX_Control(pDX, IDC_STATIC_MEMORY, m_disp_memory); +} + +BEGIN_MESSAGE_MAP(CTrafficMonitorDlg, CDialogEx) + ON_WM_QUERYDRAGICON() + ON_WM_TIMER() + ON_WM_RBUTTONUP() + ON_WM_LBUTTONDOWN() + ON_COMMAND(ID_NETWORK_INFO, &CTrafficMonitorDlg::OnNetworkInfo) + ON_COMMAND(ID_ALWAYS_ON_TOP, &CTrafficMonitorDlg::OnAlwaysOnTop) + ON_UPDATE_COMMAND_UI(ID_ALWAYS_ON_TOP, &CTrafficMonitorDlg::OnUpdateAlwaysOnTop) + ON_WM_INITMENUPOPUP() + ON_COMMAND(ID_TRANSPARENCY_100, &CTrafficMonitorDlg::OnTransparency100) + ON_COMMAND(ID_TRANSPARENCY_80, &CTrafficMonitorDlg::OnTransparency80) + ON_COMMAND(ID_TRANSPARENCY_60, &CTrafficMonitorDlg::OnTransparency60) + ON_COMMAND(ID_TRANSPARENCY_40, &CTrafficMonitorDlg::OnTransparency40) + ON_WM_CLOSE() + ON_WM_INITMENU() + ON_COMMAND(ID_LOCK_WINDOW_POS, &CTrafficMonitorDlg::OnLockWindowPos) + ON_UPDATE_COMMAND_UI(ID_LOCK_WINDOW_POS, &CTrafficMonitorDlg::OnUpdateLockWindowPos) + ON_WM_MOVE() + ON_MESSAGE(MY_WM_NOTIFYICON, &CTrafficMonitorDlg::OnNotifyIcon) + ON_COMMAND(ID_SHOW_NOTIFY_ICON, &CTrafficMonitorDlg::OnShowNotifyIcon) + ON_UPDATE_COMMAND_UI(ID_SHOW_NOTIFY_ICON, &CTrafficMonitorDlg::OnUpdateShowNotifyIcon) + ON_WM_DESTROY() + ON_COMMAND(ID_SHOW_CPU_MEMORY, &CTrafficMonitorDlg::OnShowCpuMemory) + ON_UPDATE_COMMAND_UI(ID_SHOW_CPU_MEMORY, &CTrafficMonitorDlg::OnUpdateShowCpuMemory) + ON_COMMAND(ID_MOUSE_PENETRATE, &CTrafficMonitorDlg::OnMousePenetrate) + ON_UPDATE_COMMAND_UI(ID_MOUSE_PENETRATE, &CTrafficMonitorDlg::OnUpdateMousePenetrate) + ON_COMMAND(ID_SHOW_TASK_BAR_WND, &CTrafficMonitorDlg::OnShowTaskBarWnd) + ON_UPDATE_COMMAND_UI(ID_SHOW_TASK_BAR_WND, &CTrafficMonitorDlg::OnUpdateShowTaskBarWnd) + ON_COMMAND(ID_APP_ABOUT, &CTrafficMonitorDlg::OnAppAbout) + ON_COMMAND(ID_SHOW_CPU_MEMORY2, &CTrafficMonitorDlg::OnShowCpuMemory2) + ON_COMMAND(ID_AUTO_RUN_WHEN_START, &CTrafficMonitorDlg::OnAutoRunWhenStart) + ON_COMMAND(ID_HIDE_MAIN_WND, &CTrafficMonitorDlg::OnHideMainWnd) + ON_UPDATE_COMMAND_UI(ID_HIDE_MAIN_WND, &CTrafficMonitorDlg::OnUpdateHideMainWnd) + ON_COMMAND(ID_CHANGE_SKIN, &CTrafficMonitorDlg::OnChangeSkin) + ON_UPDATE_COMMAND_UI(ID_AUTO_RUN_WHEN_START, &CTrafficMonitorDlg::OnUpdateAutoRunWhenStart) + ON_REGISTERED_MESSAGE(m_WM_TASKBARCREATED, &CTrafficMonitorDlg::OnTaskBarCreated) + ON_COMMAND(ID_TRAFFIC_HISTORY, &CTrafficMonitorDlg::OnTrafficHistory) + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDBLCLK() + ON_COMMAND(ID_OPTIONS, &CTrafficMonitorDlg::OnOptions) + ON_COMMAND(ID_OPTIONS2, &CTrafficMonitorDlg::OnOptions2) +END_MESSAGE_MAP() + + +void CTrafficMonitorDlg::ShowInfo() +{ + CString str; + CString in_speed = CCommon::DataSizeToString(theApp.m_in_speed); + CString out_speed = CCommon::DataSizeToString(theApp.m_out_speed); + + if (!theApp.m_swap_up_down) + { + str.Format(_T("%s%s/s"), theApp.m_up_string.c_str(), out_speed.GetString()); + m_disp_up.SetWindowTextEx(str); + str.Format(_T("%s%s/s"), theApp.m_down_string.c_str(), in_speed.GetString()); + m_disp_down.SetWindowTextEx(str); + } + else //ϴλ + { + str.Format(_T("%s%s/s"), theApp.m_down_string.c_str(), in_speed.GetString()); + m_disp_up.SetWindowTextEx(str); + str.Format(_T("%s%s/s"), theApp.m_up_string.c_str(), out_speed.GetString()); + m_disp_down.SetWindowTextEx(str); + } + if (m_show_cpu_memory) + { + str.Format(_T("%s%d%%"), theApp.m_cpu_string.c_str(), theApp.m_cpu_usage); + m_disp_cpu.SetWindowTextEx(str); + str.Format(_T("%s%d%%"), theApp.m_memory_string.c_str(), theApp.m_memory_usage); + m_disp_memory.SetWindowTextEx(str); + } + else + { + m_disp_cpu.SetWindowText(_T("")); + m_disp_memory.SetWindowText(_T("")); + } +} + +void CTrafficMonitorDlg::SetTransparency() +{ + SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); + SetLayeredWindowAttributes(0, m_transparency * 255 / 100, LWA_ALPHA); //͸ȡֵΧΪ0~255 +} + +void CTrafficMonitorDlg::SetAlwaysOnTop() +{ + if (!m_is_foreground_fullscreen || (m_is_foreground_fullscreen && !theApp.m_hide_main_wnd_when_fullscreen)) + { + if (m_always_on_top) + SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ö + else + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ȡö + } +} + +void CTrafficMonitorDlg::SetMousePenetrate() +{ + if (m_mouse_penetrate) + { + SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT); //괩͸ + if (!theApp.m_show_notify_icon) //괩͸ʱ֪ͨͼûʾʾ޷Ҽ˵ + { + //֪ͨͼ + AddNotifyIcon(); + theApp.m_show_notify_icon = true; + } + } + else + { + SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) & (~WS_EX_TRANSPARENT)); //ȡ괩͸ + } +} + +void CTrafficMonitorDlg::CheckWindowPos() +{ + CRect rect; + GetWindowRect(rect); + if (rect.left < 0) + { + rect.MoveToX(0); + MoveWindow(rect); + } + if (rect.top < 0) + { + rect.MoveToY(0); + MoveWindow(rect); + } + if (rect.right > m_screen_width) + { + rect.MoveToX(m_screen_width - rect.Width()); + MoveWindow(rect); + } + if (rect.bottom > m_screen_height) + { + rect.MoveToY(m_screen_height - rect.Height()); + MoveWindow(rect); + } +} + +void CTrafficMonitorDlg::GetScreenSize(int compensition_value) +{ + m_screen_width = GetSystemMetrics(SM_CXFULLSCREEN); + m_screen_height = GetSystemMetrics(SM_CYFULLSCREEN) + compensition_value; +} + +void CTrafficMonitorDlg::LoadConfig() +{ + m_transparency = GetPrivateProfileInt(_T("config"), _T("transparency"), 80, theApp.m_config_path.c_str()); + m_always_on_top = (GetPrivateProfileInt(_T("config"), _T("always_on_top"), 1, theApp.m_config_path.c_str()) != 0); + m_lock_window_pos = (GetPrivateProfileInt(_T("config"), _T("lock_window_pos"), 0, theApp.m_config_path.c_str()) != 0); + theApp.m_show_notify_icon = (GetPrivateProfileInt(_T("config"), _T("show_notify_icon"), 1, theApp.m_config_path.c_str()) != 0); + m_show_cpu_memory = (GetPrivateProfileInt(_T("config"), _T("show_cpu_memory"), 1, theApp.m_config_path.c_str()) != 0); + m_mouse_penetrate = (GetPrivateProfileInt(_T("config"), _T("mouse_penetrate"), 0, theApp.m_config_path.c_str()) != 0); + m_show_task_bar_wnd = (GetPrivateProfileInt(_T("config"), _T("show_task_bar_wnd"), 0, theApp.m_config_path.c_str()) != 0); + m_position_x = GetPrivateProfileInt(_T("config"), _T("position_x"), -1, theApp.m_config_path.c_str()); + m_position_y = GetPrivateProfileInt(_T("config"), _T("position_y"), -1, theApp.m_config_path.c_str()); + m_auto_select = (GetPrivateProfileInt(_T("connection"), _T("auto_select"), 1, theApp.m_config_path.c_str()) != 0); + theApp.m_text_color = GetPrivateProfileInt(_T("config"), _T("text_color"), 16384, theApp.m_config_path.c_str()); + theApp.m_hide_main_window = (GetPrivateProfileInt(_T("config"), _T("hide_main_window"), 0, theApp.m_config_path.c_str()) != 0); + wchar_t buff[256]; + GetPrivateProfileStringW(L"connection", L"connection_name", L"", buff, 256, theApp.m_config_path.c_str()); + m_connection_name = CCommon::UnicodeToStr(buff); + wchar_t wbuff[32]; + GetPrivateProfileString(_T("config"), _T("skin_selected"), _T(""), wbuff, 32, theApp.m_config_path.c_str()); + m_skin_name = wbuff; + if (m_skin_name.substr(0, 8) == L".\\skins\\") //ȡƤǰ".\\skins\\"ɾںǰһ汾ּԣ + m_skin_name = m_skin_name.substr(7); + theApp.m_swap_up_down = (GetPrivateProfileInt(_T("config"), _T("swap_up_down"), 0, theApp.m_config_path.c_str()) != 0); + theApp.m_hide_main_wnd_when_fullscreen = (GetPrivateProfileInt(_T("config"), _T("hide_main_wnd_when_fullscreen"), 1, theApp.m_config_path.c_str()) != 0); + + GetPrivateProfileString(_T("config"), _T("font_name"), _T("΢ź"), theApp.m_font_name.GetBuffer(32), 32, theApp.m_config_path.c_str()); + theApp.m_font_size = GetPrivateProfileInt(_T("config"), _T("font_size"), 10, theApp.m_config_path.c_str()); + + GetPrivateProfileStringW(L"config", L"up_string", L"ϴ: $", buff, 256, theApp.m_config_path.c_str()); + theApp.m_up_string = buff; + if (!theApp.m_up_string.empty() && theApp.m_up_string.back() == L'$') //ȡַĩβ'$'ɾڽȡiniļַʱ޷ӮȡĩβĿո⣬ʱֻҪĩβ'$' + theApp.m_up_string.pop_back(); + GetPrivateProfileStringW(L"config", L"down_string", L": $", buff, 256, theApp.m_config_path.c_str()); + theApp.m_down_string = buff; + if (!theApp.m_down_string.empty() && theApp.m_down_string.back() == L'$') + theApp.m_down_string.pop_back(); + GetPrivateProfileStringW(L"config", L"cpu_string", L"CPU: $", buff, 256, theApp.m_config_path.c_str()); + theApp.m_cpu_string = buff; + if (!theApp.m_cpu_string.empty() && theApp.m_cpu_string.back() == L'$') + theApp.m_cpu_string.pop_back(); + GetPrivateProfileStringW(L"config", L"memory_string", L"ڴ: $", buff, 256, theApp.m_config_path.c_str()); + theApp.m_memory_string = buff; + if (!theApp.m_memory_string.empty() && theApp.m_memory_string.back() == L'$') + theApp.m_memory_string.pop_back(); +} + +void CTrafficMonitorDlg::SaveConfig() +{ + //ǰȻȡڵλ + CRect rect; + GetWindowRect(rect); + m_position_x = rect.left; + m_position_y = rect.top; + if (!CCommon::WritePrivateProfileIntW(L"config", L"transparency", m_transparency, theApp.m_config_path.c_str())) + { + if (m_cannot_save_config_warning) + MessageBox(_T("棺޷ãǷĿ¼дݵȨޣԹԱгܻ⡣"), NULL, MB_ICONWARNING); + m_cannot_save_config_warning = false; + return; + } + CCommon::WritePrivateProfileIntW(L"config", L"always_on_top", m_always_on_top, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"lock_window_pos", m_lock_window_pos, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"show_notify_icon", theApp.m_show_notify_icon, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"show_cpu_memory", m_show_cpu_memory, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"mouse_penetrate", m_mouse_penetrate, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"show_task_bar_wnd", m_show_task_bar_wnd, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"position_x", m_position_x, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"position_y", m_position_y, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"connection", L"auto_select", m_auto_select, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"text_color", theApp.m_text_color, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"hide_main_window", theApp.m_hide_main_window, theApp.m_config_path.c_str()); + m_connection_name = m_connections[m_connection_selected].description; + WritePrivateProfileStringW(L"connection", L"connection_name", CCommon::StrToUnicode(m_connection_name.c_str()).c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("config"), _T("skin_selected"), m_skin_name.c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("config"), _T("font_name"), theApp.m_font_name, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"font_size", theApp.m_font_size, theApp.m_config_path.c_str()); + + CCommon::WritePrivateProfileIntW(L"config", L"swap_up_down", theApp.m_swap_up_down, theApp.m_config_path.c_str()); + CCommon::WritePrivateProfileIntW(L"config", L"hide_main_wnd_when_fullscreen", theApp.m_hide_main_wnd_when_fullscreen, theApp.m_config_path.c_str()); + + WritePrivateProfileString(_T("config"), _T("up_string"), (theApp.m_up_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("config"), _T("down_string"), (theApp.m_down_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("config"), _T("cpu_string"), (theApp.m_cpu_string + L'$').c_str(), theApp.m_config_path.c_str()); + WritePrivateProfileString(_T("config"), _T("memory_string"), (theApp.m_memory_string + L'$').c_str(), theApp.m_config_path.c_str()); +} + +void CTrafficMonitorDlg::AutoSelect() +{ + unsigned int max_in_out_bytes{}; + unsigned int in_out_bytes; + //m_connection_selected = m_connections[0].index; + m_connection_selected = 0; + //Զѡʱѷͺѽֽ֮ǸӣΪǰ鿴 + for (int i{}; itable[m_connections[i].index].dwOperStatus == IF_OPER_STATUS_OPERATIONAL) //ֻѡ״̬Ϊ + { + in_out_bytes = m_pIfTable->table[m_connections[i].index].dwInOctets + m_pIfTable->table[m_connections[i].index].dwOutOctets; + if (in_out_bytes > max_in_out_bytes) + { + max_in_out_bytes = in_out_bytes; + m_connection_selected = i; + } + } + } +} + +void CTrafficMonitorDlg::IniConnection() +{ + //Ϊm_pIfTableСڴ + free(m_pIfTable); + m_dwSize = sizeof(MIB_IFTABLE); + m_pIfTable = (MIB_IFTABLE *)malloc(m_dwSize); + int rtn; + rtn = GetIfTable(m_pIfTable, &m_dwSize, FALSE); + if (rtn == ERROR_INSUFFICIENT_BUFFER) //ֵΪERROR_INSUFFICIENT_BUFFER˵m_pIfTableĴС + { + free(m_pIfTable); + m_pIfTable = (MIB_IFTABLE *)malloc(m_dwSize); //µĴС¿һڴ + } + //ȡǰеӣ浽m_connections + m_connections.clear(); + GetIfTable(m_pIfTable, &m_dwSize, FALSE); + for (unsigned int i{}; i < m_pIfTable->dwNumEntries; i++) + { + string descr = (const char*)m_pIfTable->table[i].bDescr; + if (m_pIfTable->table[i].dwInOctets > 0 || m_pIfTable->table[i].dwOutOctets > 0 || descr == m_connection_name) //ҽջ0Ӻϴѡ + { + m_connections.emplace_back(i, descr, m_pIfTable->table[i].dwInOctets, m_pIfTable->table[i].dwOutOctets); + } + } + if (m_connections.empty()) + m_connections.emplace_back(0, string((const char*)m_pIfTable->table[0].bDescr), 0, 0); + + //if (m_connection_selected < 0 || m_connection_selected >= m_connections.size() || m_auto_select) + // AutoSelect(); + //ѡ + if (m_auto_select) //Զѡ + { + if (m_restart_cnt != -1) //m_restart_cnt-1ʱǵһγʼʱҪʱ5³ʼ + { + KillTimer(DELAY_TIMER); + SetTimer(DELAY_TIMER, 5000, NULL); + } + else + { + AutoSelect(); + } + } + else //Ϊϴѡ + { + m_connection_selected = 0; + for (size_t i{}; i < m_connections.size(); i++) + { + if (m_connections[i].description == m_connection_name) + m_connection_selected = i; + } + } + m_connection_name = m_connections[m_connection_selected].description; + + //ѻȡڲ˵ӦĿ + m_menu.DestroyMenu(); + 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++) + { + 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); + } + + m_restart_cnt++; //¼ʼ + m_connection_change_flag = true; +} + +void CTrafficMonitorDlg::CloseTaskBarWnd() +{ + m_tBarDlg->OnCancel(); + delete m_tBarDlg; + m_tBarDlg = nullptr; +} + +void CTrafficMonitorDlg::OpenTaskBarWnd() +{ + ////ûöڴʱöȡöԽڵʾʾ + //if (!m_always_on_top) + // SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ö + m_tBarDlg = new CTaskBarDlg; + m_tBarDlg->Create(IDD_TASK_BAR_DIALOG, this); + m_tBarDlg->ShowWindow(SW_SHOW); + m_tBarDlg->ShowInfo(); + //if (!m_always_on_top) + // SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ȡö +} + +void CTrafficMonitorDlg::AddNotifyIcon() +{ + if (m_show_task_bar_wnd) + CloseTaskBarWnd(); + //֪ͨͼ + ::Shell_NotifyIcon(NIM_ADD, &m_ntIcon); + if (m_show_task_bar_wnd) + OpenTaskBarWnd(); +} + +void CTrafficMonitorDlg::DeleteNotifyIcon() +{ + if (m_show_task_bar_wnd) + CloseTaskBarWnd(); + //ɾ֪ͨͼ + ::Shell_NotifyIcon(NIM_DELETE, &m_ntIcon); + if (m_show_task_bar_wnd) + OpenTaskBarWnd(); +} + +void CTrafficMonitorDlg::SaveHistoryTraffic() +{ + ofstream file{ theApp.m_history_traffic_path }; + for (const auto& history_traffic : m_history_traffics) + { + char date_str[16]; + sprintf_s(date_str, "%.4d/%.2d/%.2d ", history_traffic.year, history_traffic.month, history_traffic.day); + file << date_str << history_traffic.kBytes << std::endl; + } +} + +void CTrafficMonitorDlg::LoadHistoryTraffic() +{ + ifstream file{ theApp.m_history_traffic_path }; + string current_line, temp; + HistoryTraffic traffic; + if (CCommon::FileExist(theApp.m_history_traffic_path.c_str())) + { + while (!file.eof()) + { + if (m_history_traffics.size() > 999) break; //ȡ1000ʷ¼ + std::getline(file, current_line); + if (current_line.size() < 12) continue; + temp = current_line.substr(0, 4); + traffic.year = atoi(temp.c_str()); + temp = current_line.substr(5, 2); + traffic.month = atoi(temp.c_str()); + temp = current_line.substr(8, 2); + traffic.day = atoi(temp.c_str()); + temp = current_line.substr(11); + traffic.kBytes = atoi(temp.c_str()); + m_history_traffics.push_back(traffic); + } + } + + SYSTEMTIME current_time; + GetLocalTime(¤t_time); + traffic.year = current_time.wYear; + traffic.month = current_time.wMonth; + traffic.day = current_time.wDay; + traffic.kBytes = 0; + + if (m_history_traffics.empty()) + { + m_history_traffics.push_front(traffic); + } + + if (m_history_traffics.size() >= 2) + { + //ȡʷбڴӴС + std::sort(m_history_traffics.begin(), m_history_traffics.end(), HistoryTraffic::DateGreater); + + //бͬڵĿϲ + for (int i{}; i < m_history_traffics.size() - 1; i++) + { + if (HistoryTraffic::DateEqual(m_history_traffics[i], m_history_traffics[i + 1])) + { + m_history_traffics[i].kBytes += m_history_traffics[i + 1].kBytes; + m_history_traffics.erase(m_history_traffics.begin() + i + 1); + } + } + } + + //бһĿǽ죬򽫵һĿͳƵΪʹõбǰһΪĿ + if (HistoryTraffic::DateEqual(m_history_traffics[0], traffic)) + theApp.m_today_traffic = static_cast<__int64>(m_history_traffics[0].kBytes) * 1024; + else + m_history_traffics.push_front(traffic); + +} + +void CTrafficMonitorDlg::_OnOptions(int tab) +{ + COptionsDlg optionsDlg(tab); + //ѡݴݸѡöԻ + optionsDlg.m_tab1_dlg.m_font_name = theApp.m_font_name; + optionsDlg.m_tab1_dlg.m_font_size = theApp.m_font_size; + optionsDlg.m_tab1_dlg.m_text_color = theApp.m_text_color; + optionsDlg.m_tab1_dlg.m_up_string = theApp.m_up_string; + optionsDlg.m_tab1_dlg.m_down_string = theApp.m_down_string; + optionsDlg.m_tab1_dlg.m_cpu_string = theApp.m_cpu_string; + optionsDlg.m_tab1_dlg.m_memory_string = theApp.m_memory_string; + optionsDlg.m_tab1_dlg.m_swap_up_down = theApp.m_swap_up_down; + optionsDlg.m_tab1_dlg.m_hide_main_wnd_when_fullscreen = theApp.m_hide_main_wnd_when_fullscreen; + + optionsDlg.m_tab2_dlg.m_font_name = theApp.m_tbar_font_name; + optionsDlg.m_tab2_dlg.m_font_size = theApp.m_tbar_font_size; + optionsDlg.m_tab2_dlg.m_text_color = theApp.m_tbar_text_color; + optionsDlg.m_tab2_dlg.m_back_color = theApp.m_tbar_back_color; + optionsDlg.m_tab2_dlg.m_up_string = theApp.m_tbar_up_string; + optionsDlg.m_tab2_dlg.m_down_string = theApp.m_tbar_down_string; + optionsDlg.m_tab2_dlg.m_cpu_string = theApp.m_tbar_cpu_string; + optionsDlg.m_tab2_dlg.m_memory_string = theApp.m_tbar_memory_string; + optionsDlg.m_tab2_dlg.m_swap_up_down = theApp.m_tbar_swap_up_down; + + if (optionsDlg.DoModal() == IDOK) + { + theApp.m_font_name = optionsDlg.m_tab1_dlg.m_font_name; + theApp.m_font_size = optionsDlg.m_tab1_dlg.m_font_size; + theApp.m_text_color = optionsDlg.m_tab1_dlg.m_text_color; + theApp.m_up_string = optionsDlg.m_tab1_dlg.m_up_string; + theApp.m_down_string = optionsDlg.m_tab1_dlg.m_down_string; + theApp.m_cpu_string = optionsDlg.m_tab1_dlg.m_cpu_string; + theApp.m_memory_string = optionsDlg.m_tab1_dlg.m_memory_string; + theApp.m_swap_up_down = optionsDlg.m_tab1_dlg.m_swap_up_down; + theApp.m_hide_main_wnd_when_fullscreen = optionsDlg.m_tab1_dlg.m_hide_main_wnd_when_fullscreen; + ApplySettings(); + SaveConfig(); + + theApp.m_tbar_font_name = optionsDlg.m_tab2_dlg.m_font_name; + theApp.m_tbar_font_size = optionsDlg.m_tab2_dlg.m_font_size; + theApp.m_tbar_text_color = optionsDlg.m_tab2_dlg.m_text_color; + theApp.m_tbar_back_color = optionsDlg.m_tab2_dlg.m_back_color; + theApp.m_tbar_up_string = optionsDlg.m_tab2_dlg.m_up_string; + theApp.m_tbar_down_string = optionsDlg.m_tab2_dlg.m_down_string; + theApp.m_tbar_cpu_string = optionsDlg.m_tab2_dlg.m_cpu_string; + theApp.m_tbar_memory_string = optionsDlg.m_tab2_dlg.m_memory_string; + theApp.m_tbar_swap_up_down = optionsDlg.m_tab2_dlg.m_swap_up_down; + CTaskBarDlg::SaveConfig(); + if (m_tBarDlg != nullptr) + { + m_tBarDlg->ApplySettings(); + //ʾıڿҪ仯ǹرٴ + CloseTaskBarWnd(); + OpenTaskBarWnd(); + } + } +} + +void CTrafficMonitorDlg::ApplySettings() +{ + //Ӧɫ + m_disp_cpu.SetTextColor(theApp.m_text_color); + m_disp_memory.SetTextColor(theApp.m_text_color); + m_disp_up.SetTextColor(theApp.m_text_color); + m_disp_down.SetTextColor(theApp.m_text_color); + //Ӧ + if (m_font.m_hObject) //m_fontѾһԴͷ + m_font.DeleteObject(); + m_font.CreatePointFont(theApp.m_font_size * 10, theApp.m_font_name); + m_disp_cpu.SetFont(&m_font); + m_disp_memory.SetFont(&m_font); + m_disp_up.SetFont(&m_font); + m_disp_down.SetFont(&m_font); +} + +// CTrafficMonitorDlg Ϣ + +BOOL CTrafficMonitorDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // ô˶Իͼꡣ ӦóڲǶԻʱܽԶ + // ִд˲ + SetIcon(m_hIcon, TRUE); // ôͼ + SetIcon(m_hIcon, FALSE); // Сͼ + + // TODO: ڴӶijʼ + SetWindowText(_T("TrafficMonitor")); + //ͼ + ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW); + + //ô͸ + SetTransparency(); + + IniConnection(); //ʼ + + //ʱ괩͸ڣûʾڣʾ֪ͨͼ + if ((m_mouse_penetrate || theApp.m_hide_main_window) && !m_show_task_bar_wnd) + theApp.m_show_notify_icon = true; + + //֪ͨͼ + m_ntIcon.cbSize = sizeof(NOTIFYICONDATA); //ýṹĴС + m_ntIcon.hIcon = AfxGetApp()->LoadIcon(IDI_NOFITY_ICON); //ͼ꣬ͨԴIDõ + m_ntIcon.hWnd = this->m_hWnd; //ͼ֪ͨϢĴھ + TCHAR atip[128] = _T(""); //ָͼʱʾʾ + wcscpy_s(m_ntIcon.szTip, 128, atip); + m_ntIcon.uCallbackMessage = MY_WM_NOTIFYICON; //ӦóϢID + m_ntIcon.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; //ͼԣóԱuCallbackMessagehIconszTipЧ + if (theApp.m_show_notify_icon) + ::Shell_NotifyIcon(NIM_ADD, &m_ntIcon); //ϵͳ֪ͨͼ + + //ʷ¼ + LoadHistoryTraffic(); + + //1000봥Ķʱ + SetTimer(MAIN_TIMER, 1000, NULL); + + //ʼλ + CRect rect; + GetWindowRect(rect); + if (m_position_x != -1 && m_position_y != -1) + rect.MoveToXY(m_position_x, m_position_y); + + m_window_height = rect.Height(); + //ʾCPUڴʱĴڸ߶Ϊԭ64%0.5ڲfloatתΪintʱ뵼µ + //ڲͬDPIõĵʱڵĴСȷģֻܰ + m_window_height_s = static_cast(rect.Height() * 0.64f + 0.5f); + + if (!m_show_cpu_memory) + rect.bottom = rect.top + m_window_height_s; + MoveWindow(rect); + CheckWindowPos(); + + //ʼƤ + CCommon::GetFiles(theApp.m_skin_path.c_str(), m_skins); + if (m_skins.empty()) + m_skins.push_back(L""); + m_skin_selected = 0; + for (unsigned int i{}; i(m_hIcon); +} + + +void CTrafficMonitorDlg::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: ڴϢ/Ĭֵ + if (nIDEvent == MAIN_TIMER) + { + if (m_first_start) //ifڳ1ִ + { + //ôöĴڽ + //ڳʼпܻöЧ + SetAlwaysOnTop(); //ôö + SetMousePenetrate(); //괩͸ + if (theApp.m_hide_main_window) // + ShowWindow(SW_HIDE); + + if (!CCommon::WhenStart()) + { + if (m_show_task_bar_wnd && m_tBarDlg == nullptr) + OpenTaskBarWnd(); + } + + m_first_start = false; + } + + //2ʾڣֹʱûмصǶʧܵ + if (CCommon::WhenStart() && m_timer_cnt == 2) + { + if (m_show_task_bar_wnd && m_tBarDlg == nullptr) + OpenTaskBarWnd(); + } + + if (m_always_on_top) + { + //ÿ1Ӿжһǰ̨Ƿȫ + m_is_foreground_fullscreen = CCommon::IsForegroundFullscreen(); + if (theApp.m_hide_main_wnd_when_fullscreen) //ȫʱʱ + { + if(m_is_foreground_fullscreen || theApp.m_hide_main_window) + ShowWindow(SW_HIDE); + else + ShowWindow(SW_RESTORE); + } + else //ûȫʱгȫ״̬һδö + { + static bool last_foreground_fullscreen; + if (!last_foreground_fullscreen && m_is_foreground_fullscreen) + { + SetAlwaysOnTop(); + } + last_foreground_fullscreen = m_is_foreground_fullscreen; + } + } + + //ʱִСö괩͸͡ڡIJֹûЧ + if (m_timer_cnt == 5 || m_timer_cnt == 9) + { + if (!theApp.m_hide_main_window) + { + SetAlwaysOnTop(); + SetMousePenetrate(); + } + else + { + ShowWindow(SW_HIDE); + } + } + + if (m_timer_cnt % 300 == 299 && !theApp.m_hide_main_window && m_always_on_top) + { + SetAlwaysOnTop(); //ÿ5ִһôö + } + + //ֻںһʾʱִĴ + if (!theApp.m_hide_main_window || m_show_task_bar_wnd) + { + //ȡٶ + int rtn = GetIfTable(m_pIfTable, &m_dwSize, FALSE); + m_in_bytes = m_pIfTable->table[m_connections[m_connection_selected].index].dwInOctets; + m_out_bytes = m_pIfTable->table[m_connections[m_connection_selected].index].dwOutOctets; + + //ͺͽյֽΪ0ϴηͺͽյֽΪ0ǰѸıʱЧ + if ((m_in_bytes == 0 && m_out_bytes == 0) || (m_last_in_bytes == 0 && m_last_out_bytes) || m_connection_change_flag) + { + theApp.m_in_speed = 0; + theApp.m_out_speed = 0; + } + else + { + theApp.m_in_speed = m_in_bytes - m_last_in_bytes; + theApp.m_out_speed = m_out_bytes - m_last_out_bytes; + } + //1GB/s˵ܲ쳣Ч + if (theApp.m_in_speed > 1073741824) + theApp.m_in_speed = 0; + if (theApp.m_out_speed > 1073741824) + theApp.m_out_speed = 0; + + m_connection_change_flag = false; //ӷ仯ı־ + + m_last_in_bytes = m_in_bytes; + m_last_out_bytes = m_out_bytes; + + //Զѡ״̬ʱ30û٣Զѡ粻ԣʱִһԶѡ + if (m_auto_select) + { + if (theApp.m_in_speed == 0 && theApp.m_out_speed == 0) + m_zero_speed_cnt++; + else + m_zero_speed_cnt = 0; + if (m_zero_speed_cnt >= 30) + { + AutoSelect(); + m_zero_speed_cnt = 0; + } + } + + //⵱ǰǷı䣬Ѹı䣬ʷбһµ + SYSTEMTIME current_time; + GetLocalTime(¤t_time); + if (m_history_traffics[0].day != current_time.wDay) + { + HistoryTraffic traffic; + traffic.year = current_time.wYear; + traffic.month = current_time.wMonth; + traffic.day = current_time.wDay; + traffic.kBytes = 0; + m_history_traffics.push_front(traffic); + theApp.m_today_traffic = 0; + } + + //ͳƽʹõ + theApp.m_today_traffic += (theApp.m_in_speed + theApp.m_out_speed); + m_history_traffics[0].kBytes = static_cast(theApp.m_today_traffic / 1024); + //ÿ30뱣һʷ¼ + if (m_timer_cnt % 30 == 10) + SaveHistoryTraffic(); + + char buff[256]; + if (rtn == ERROR_INSUFFICIENT_BUFFER) + { + IniConnection(); + sprintf_s(buff, "ڴϢĻС³ʼӡ(³ʼ%d)", m_restart_cnt); + CCommon::WriteLog(buff, theApp.m_log_path.c_str()); + } + + //ͳƵǰѷͻѽֽΪ0Ӹ + int connection_count{}; + string descr; + for (unsigned int i{}; i < m_pIfTable->dwNumEntries; i++) + { + descr = (const char*)m_pIfTable->table[i].bDescr; + if (m_pIfTable->table[i].dwInOctets > 0 || m_pIfTable->table[i].dwOutOctets > 0 || descr == m_connection_name) + connection_count++; + } + if (connection_count == 0) connection_count = 1; + if (connection_count != m_connections.size()) //仯³ʼ + { + sprintf_s(buff, "⵽仯»ȡӡǰ%d%d(³ʼ%d)", m_connections.size(), connection_count, m_restart_cnt + 1); + IniConnection(); + CCommon::WriteLog(buff, theApp.m_log_path.c_str()); + } + descr = (const char*)m_pIfTable->table[m_connections[m_connection_selected].index].bDescr; + if (descr != m_connection_name) + { + IniConnection(); + sprintf_s(buff, "ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ%d)", m_restart_cnt); + CCommon::WriteLog(buff, theApp.m_log_path.c_str()); + } + + + if (m_show_cpu_memory || (m_tBarDlg != nullptr && theApp.m_tbar_show_cpu_memory)) + { + //ȡCPU + FILETIME idleTime; + FILETIME kernelTime; + FILETIME userTime; + GetSystemTimes(&idleTime, &kernelTime, &userTime); + + __int64 idle = CCommon::CompareFileTime2(m_preidleTime, idleTime); + __int64 kernel = CCommon::CompareFileTime2(m_prekernelTime, kernelTime); + __int64 user = CCommon::CompareFileTime2(m_preuserTime, userTime); + + if (kernel + user == 0) + { + theApp.m_cpu_usage = 0; + } + else + { + //ܵʱ-ʱ䣩/ܵʱ=ռcpuʱʹ + theApp.m_cpu_usage = static_cast(abs((kernel + user - idle) * 100 / (kernel + user))); + } + m_preidleTime = idleTime; + m_prekernelTime = kernelTime; + m_preuserTime = userTime; + + //ȡڴ + MEMORYSTATUSEX statex; + statex.dwLength = sizeof(statex); + GlobalMemoryStatusEx(&statex); + theApp.m_memory_usage = statex.dwMemoryLoad; + theApp.m_used_memory = static_cast((statex.ullTotalPhys - statex.ullAvailPhys) / 1024); + theApp.m_total_memory = static_cast(statex.ullTotalPhys / 1024); + } + + ShowInfo(); //ˢ´Ϣ + + //Ϣ + if (m_tBarDlg != nullptr) + { + //ʾڼ䣬ʱڵλãֹͼڵ + m_tBarDlg->AdjustWindowPos(); + m_tBarDlg->ShowInfo(); + } + } + + m_timer_cnt++; + } + + if (nIDEvent == DELAY_TIMER) + { + AutoSelect(); + KillTimer(DELAY_TIMER); + } + + CDialogEx::OnTimer(nIDEvent); +} + + +void CTrafficMonitorDlg::OnRButtonUp(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + //õҼ˵ + CMenu* pContextMenu = m_menu.GetSubMenu(0); //ȡһ˵Եһ˵Ӳ˵ + CPoint point1; //һȷλõλ + GetCursorPos(&point1); //ȡǰλãԱʹò˵Ը + pContextMenu->SetDefaultItem(ID_NETWORK_INFO); + pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point1.x, point1.y, this); //ָλʾ˵ + + CDialogEx::OnRButtonUp(nFlags, point1); +} + + +void CTrafficMonitorDlg::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + //δλʱͨڲ϶ + if (!m_lock_window_pos) + PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y)); + CDialogEx::OnLButtonDown(nFlags, point); +} + + +void CTrafficMonitorDlg::OnNetworkInfo() +{ + // TODO: ڴ + //顱Ի + CNetworkInfoDlg aDlg(m_pIfTable->table[m_connections[m_connection_selected].index]); + //CNetworkInfoDlgഫѷͺͽյֽ + aDlg.m_in_bytes = m_pIfTable->table[m_connections[m_connection_selected].index].dwInOctets - m_connections[m_connection_selected].in_bytes; + aDlg.m_out_bytes = m_pIfTable->table[m_connections[m_connection_selected].index].dwOutOctets - m_connections[m_connection_selected].out_bytes; + aDlg.m_start_time = m_start_time; + aDlg.DoModal(); + //SetAlwaysOnTop(); //ڡ顱ԻȡöڶԻرպôö + if(m_tBarDlg!=nullptr) + m_tBarDlg->m_tool_tips.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); //ڵʾϢö +} + + +void CTrafficMonitorDlg::OnAlwaysOnTop() +{ + // TODO: ڴ + m_always_on_top = !m_always_on_top; + SetAlwaysOnTop(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateAlwaysOnTop(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_always_on_top); +} + + +void CTrafficMonitorDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) +{ + CDialogEx::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); + + // TODO: ڴ˴Ϣ + ASSERT(pPopupMenu != NULL); + // Check the enabled state of various menu items. + + CCmdUI state; + state.m_pMenu = pPopupMenu; + ASSERT(state.m_pOther == NULL); + ASSERT(state.m_pParentMenu == NULL); + + // Determine if menu is popup in top-level menu and set m_pOther to + // it if so (m_pParentMenu == NULL indicates that it is secondary popup). + HMENU hParentMenu; + if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu) + state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup. + else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL) + { + CWnd* pParent = this; + // Child Windows dont have menus--need to go to the top! + if (pParent != NULL && + (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL) + { + int nIndexMax = ::GetMenuItemCount(hParentMenu); + for (int nIndex = 0; nIndex < nIndexMax; nIndex++) + { + if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu) + { + // When popup is found, m_pParentMenu is containing menu. + state.m_pParentMenu = CMenu::FromHandle(hParentMenu); + break; + } + } + } + } + + state.m_nIndexMax = pPopupMenu->GetMenuItemCount(); + for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax; + state.m_nIndex++) + { + state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex); + if (state.m_nID == 0) + continue; // Menu separator or invalid cmd - ignore it. + + ASSERT(state.m_pOther == NULL); + ASSERT(state.m_pMenu != NULL); + if (state.m_nID == (UINT)-1) + { + // Possibly a popup menu, route to first item of that popup. + state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex); + if (state.m_pSubMenu == NULL || + (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 || + state.m_nID == (UINT)-1) + { + continue; // First item of popup cant be routed to. + } + state.DoUpdate(this, TRUE); // Popups are never auto disabled. + } + else + { + // Normal menu item. + // Auto enable/disable if frame window has m_bAutoMenuEnable + // set and command is _not_ a system command. + state.m_pSubMenu = NULL; + state.DoUpdate(this, FALSE); + } + + // Adjust for menu deletions and additions. + UINT nCount = pPopupMenu->GetMenuItemCount(); + if (nCount < state.m_nIndexMax) + { + state.m_nIndex -= (state.m_nIndexMax - nCount); + while (state.m_nIndex < nCount && + pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID) + { + state.m_nIndex++; + } + } + state.m_nIndexMax = nCount; + } +} + + +void CTrafficMonitorDlg::OnTransparency100() +{ + // TODO: ڴ + m_transparency = 100; + SetTransparency(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnTransparency80() +{ + // TODO: ڴ + m_transparency = 80; + SetTransparency(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnTransparency60() +{ + // TODO: ڴ + m_transparency = 60; + SetTransparency(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnTransparency40() +{ + // TODO: ڴ + m_transparency = 40; + SetTransparency(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnClose() +{ + // TODO: ڴϢ/Ĭֵ + m_cannot_save_config_warning = true; + SaveConfig(); //˳ǰõiniļ + SaveHistoryTraffic(); + + if (m_tBarDlg != nullptr) + m_tBarDlg->OnCancel(); + + CDialogEx::OnClose(); +} + + +BOOL CTrafficMonitorDlg::OnCommand(WPARAM wParam, LPARAM lParam) +{ + // TODO: ڴרô/û + UINT uMsg = LOWORD(wParam); + //ѡˡѡӡӲ˵ĿʱĴ + if (uMsg == ID_SELETE_CONNECTION) //ѡˡԶѡ񡱲˵ + { + AutoSelect(); + m_auto_select = true; + SaveConfig(); + m_connection_change_flag = true; + } + if (uMsg > ID_SELETE_CONNECTION && uMsg <= ID_SELETE_CONNECTION + m_connections.size()) //ѡһ + { + m_connection_selected = uMsg - ID_SELETE_CONNECTION - 1; + m_connection_name = m_connections[m_connection_selected].description; + m_auto_select = false; + SaveConfig(); + m_connection_change_flag = true; + } + + return CDialogEx::OnCommand(wParam, lParam); +} + + +void CTrafficMonitorDlg::OnInitMenu(CMenu* pMenu) +{ + CDialogEx::OnInitMenu(pMenu); + + // TODO: ڴ˴Ϣ + //áѡӡӲ˵иѡѡ״̬ + if (m_auto_select) //m_auto_selectΪtrueʱΪԶѡѡв˵ĵ1 + m_select_connection_menu->CheckMenuRadioItem(0, m_connections.size(), 0, MF_BYPOSITION | MF_CHECKED); + else //m_auto_selectΪfalseʱԶѡ񣬸m_connection_selectedֵѡӦ + m_select_connection_menu->CheckMenuRadioItem(0, m_connections.size(), m_connection_selected + 1, MF_BYPOSITION | MF_CHECKED); + + //áڲ͸ȡӲ˵¸ѡѡ״̬ + switch (m_transparency) + { + case 100: pMenu->CheckMenuRadioItem(ID_TRANSPARENCY_100, ID_TRANSPARENCY_40, ID_TRANSPARENCY_100, MF_BYCOMMAND | MF_CHECKED); break; + case 80: pMenu->CheckMenuRadioItem(ID_TRANSPARENCY_100, ID_TRANSPARENCY_40, ID_TRANSPARENCY_80, MF_BYCOMMAND | MF_CHECKED); break; + case 60: pMenu->CheckMenuRadioItem(ID_TRANSPARENCY_100, ID_TRANSPARENCY_40, ID_TRANSPARENCY_60, MF_BYCOMMAND | MF_CHECKED); break; + case 40: pMenu->CheckMenuRadioItem(ID_TRANSPARENCY_100, ID_TRANSPARENCY_40, ID_TRANSPARENCY_40, MF_BYCOMMAND | MF_CHECKED); break; + default: break; + } + + if(!m_show_task_bar_wnd && (theApp.m_hide_main_window || m_mouse_penetrate)) //ûʾڣڻ괩͸áʾ֪ͨͼꡱ˵ + pMenu->EnableMenuItem(ID_SHOW_NOTIFY_ICON, MF_BYCOMMAND | MF_GRAYED); + else + pMenu->EnableMenuItem(ID_SHOW_NOTIFY_ICON, MF_BYCOMMAND | MF_ENABLED); + + //pMenu->SetDefaultItem(ID_NETWORK_INFO); +} + + +BOOL CTrafficMonitorDlg::PreTranslateMessage(MSG* pMsg) +{ + // TODO: ڴרô/û + //ΰسESC˳ + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) return TRUE; + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) return TRUE; + + if (m_tool_tips.GetSafeHwnd()) + { + m_tool_tips.RelayEvent(pMsg); + } + + return CDialogEx::PreTranslateMessage(pMsg); +} + + +void CTrafficMonitorDlg::OnLockWindowPos() +{ + // TODO: ڴ + m_lock_window_pos = !m_lock_window_pos; + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateLockWindowPos(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_lock_window_pos); +} + + +void CTrafficMonitorDlg::OnMove(int x, int y) +{ + CDialogEx::OnMove(x, y); + + // TODO: ڴ˴Ϣ + //ȷڲᳬĻΧ + CheckWindowPos(); +} + + + +afx_msg LRESULT CTrafficMonitorDlg::OnNotifyIcon(WPARAM wParam, LPARAM lParam) +{ + bool dialog_exist{ false }; + const int WIND_NUM{ 6 }; + const CString diloge_title[WIND_NUM]{ _T(" TrafficMonitor"),_T(""), _T("ʷͳ"), _T(""), _T("Ƥ"), _T("ѡ") }; + HWND handle{}; + //βҳеÿһԻҵһûйرյĶԻʱҼ˵ֹûڴʱ˳ + for (int i{}; i < WIND_NUM; i++) + { + handle = ::FindWindow(NULL, diloge_title[i]); + if (handle != NULL) + { + dialog_exist = true; + break; + } + } + + if (lParam == WM_LBUTTONDOWN) + { + if (!theApp.m_hide_main_window) + { + if (dialog_exist) //д򿪵ĶԻʱ֪ͨͼ󽫽õԻ + { + ::SetForegroundWindow(handle); + } + else //ûд򿪵ĶԻʱʾ + { + ShowWindow(SW_RESTORE); + theApp.m_hide_main_window = false; + SetForegroundWindow(); + CheckWindowPos(); + SaveConfig(); + } + } + } + if (lParam == WM_RBUTTONUP && !dialog_exist) + { + //֪ͨҼҼ˵ + if (m_tBarDlg != nullptr) //ʾڣһ֪ͨͼ󽫽õ + m_tBarDlg->SetForegroundWindow(); + else //򽫽õ + SetForegroundWindow(); + CPoint point1; //һȷλõλ + GetCursorPos(&point1); //ȡǰλãԱʹò˵Ը + m_menu.GetSubMenu(0)->SetDefaultItem(-1); //ûĬϲ˵ + m_menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point1.x, point1.y, this); //ָλʾ˵ + + CheckWindowPos(); + } + if (lParam == WM_LBUTTONDBLCLK) + { + if (dialog_exist) //д򿪵ĶԻʱ֪ͨͼ󽫽õԻ + { + ::SetForegroundWindow(handle); + } + else //ûд򿪵ĶԻʱʾ + { + ShowWindow(SW_RESTORE); + theApp.m_hide_main_window = false; + SetForegroundWindow(); + CheckWindowPos(); + SaveConfig(); + } + } + return 0; +} + + +void CTrafficMonitorDlg::OnShowNotifyIcon() +{ + // TODO: ڴ + if (theApp.m_show_notify_icon) + { + DeleteNotifyIcon(); + theApp.m_show_notify_icon = false; + } + else + { + AddNotifyIcon(); + theApp.m_show_notify_icon = true; + } + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateShowNotifyIcon(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(theApp.m_show_notify_icon); +} + + +void CTrafficMonitorDlg::OnDestroy() +{ + CDialogEx::OnDestroy(); + + //˳ʱɾ֪ͨͼ + ::Shell_NotifyIcon(NIM_DELETE, &m_ntIcon); + // TODO: ڴ˴Ϣ +} + + +void CTrafficMonitorDlg::OnShowCpuMemory() +{ + // TODO: ڴ + CRect rect; + GetWindowRect(rect); + if (m_show_cpu_memory) + { + rect.bottom = rect.top + m_window_height_s; + MoveWindow(rect); + CheckWindowPos(); + m_back_img = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\background.bmp").c_str(), IMAGE_BITMAP, rect.Width(), m_window_height_s, LR_LOADFROMFILE); + m_show_cpu_memory = false; + } + else + { + rect.bottom = rect.top + m_window_height; + MoveWindow(rect); + CheckWindowPos(); + m_back_img = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\background_l.bmp").c_str(), IMAGE_BITMAP, rect.Width(), m_window_height, LR_LOADFROMFILE); + m_show_cpu_memory = true; + } + SetBackgroundImage(m_back_img); + ShowInfo(); + SaveConfig(); +} + + +//лʾCPUڴʱĴ +void CTrafficMonitorDlg::OnShowCpuMemory2() +{ + // TODO: ڴ + if (m_tBarDlg != nullptr) + { + theApp.m_tbar_show_cpu_memory = !theApp.m_tbar_show_cpu_memory; + //лʾCPUڴʱɾڣʾ + CloseTaskBarWnd(); + OpenTaskBarWnd(); + } +} + + +void CTrafficMonitorDlg::OnUpdateShowCpuMemory(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_show_cpu_memory); +} + + +void CTrafficMonitorDlg::OnMousePenetrate() +{ + // TODO: ڴ + m_mouse_penetrate = !m_mouse_penetrate; + SetMousePenetrate(); + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateMousePenetrate(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_mouse_penetrate); +} + + +void CTrafficMonitorDlg::OnShowTaskBarWnd() +{ + // TODO: ڴ + if (m_tBarDlg != nullptr) + { + CloseTaskBarWnd(); + } + if (!m_show_task_bar_wnd) + { + m_show_task_bar_wnd = true; + OpenTaskBarWnd(); + } + else + { + m_show_task_bar_wnd = false; + //رںûʾ֪ͨͼ꣬ûʾڻ괩͸֪ͨͼʾ + if (!theApp.m_show_notify_icon && (theApp.m_hide_main_window || m_mouse_penetrate)) + { + AddNotifyIcon(); + theApp.m_show_notify_icon = true; + } + } + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateShowTaskBarWnd(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_show_task_bar_wnd); +} + + +void CTrafficMonitorDlg::OnAppAbout() +{ + // TODO: ڴ + //ڡԻ + CAboutDlg aDlg; + aDlg.DoModal(); +} + + + +void CTrafficMonitorDlg::OnAutoRunWhenStart() +{ + // TODO: ڴ + if (!m_auto_run) + { + if (MessageBox(_T("ǷҪڡʼ˵ġĿ¼´Ŀݷʽ"), NULL, MB_ICONQUESTION | MB_YESNO) == IDYES) + { + if (CCommon::CreateFileShortcut(m_start_up_path.c_str(), NULL, _T("TrafficMonitor.lnk"))) + { + CString info; + info.Format(_T("Ѿڡ%s·´˳Ŀݷʽ"), m_start_up_path.c_str()); + MessageBox(info, NULL, MB_ICONINFORMATION); + m_auto_run = true; + } + else + { + MessageBox(_T("ݷʽʧܣ"), NULL, MB_ICONWARNING); + } + } + } + else + { + if (MessageBox(_T("ǷҪڡʼ˵ġĿ¼ɾĿݷʽ"), NULL, MB_ICONQUESTION | MB_YESNO) == IDYES) + { + if (DeleteFile((m_start_up_path + L"\\TrafficMonitor.lnk").c_str())) + { + MessageBox(_T("ݷʽɾɹ"), NULL, MB_ICONINFORMATION); + m_auto_run = false; + } + else + { + MessageBox(_T("ݷʽɾʧܣ"), NULL, MB_ICONWARNING); + } + } + } +} + + +void CTrafficMonitorDlg::OnUpdateAutoRunWhenStart(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(m_auto_run); +} + + +//ԴʱᴥϢ +LRESULT CTrafficMonitorDlg::OnTaskBarCreated(WPARAM wParam, LPARAM lParam) +{ + if (m_tBarDlg != nullptr) + { + CloseTaskBarWnd(); + if (theApp.m_show_notify_icon) + { + //֪ͨͼ + ::Shell_NotifyIcon(NIM_ADD, &m_ntIcon); + } + OpenTaskBarWnd(); + } + else + { + if (theApp.m_show_notify_icon) + ::Shell_NotifyIcon(NIM_ADD, &m_ntIcon); + } + return LRESULT(); +} + + +void CTrafficMonitorDlg::OnHideMainWnd() +{ + // TODO: ڴ + if (!theApp.m_hide_main_window) + { + ShowWindow(SW_HIDE); + theApp.m_hide_main_window = true; + //ںûʾ֪ͨͼ꣬ʾ + if (!theApp.m_show_notify_icon && !m_show_task_bar_wnd) + { + AddNotifyIcon(); + theApp.m_show_notify_icon = true; + } + } + else + { + ShowWindow(SW_RESTORE); + theApp.m_hide_main_window = false; + } + SaveConfig(); +} + + +void CTrafficMonitorDlg::OnUpdateHideMainWnd(CCmdUI *pCmdUI) +{ + // TODO: ڴû洦 + pCmdUI->SetCheck(theApp.m_hide_main_window); +} + + +void CTrafficMonitorDlg::OnChangeSkin() +{ + // TODO: ڴ + CRect rect; + GetWindowRect(rect); + CSkinDlg skinDlg; + //ʼCSkinDlg + skinDlg.m_skins = m_skins; + skinDlg.m_skin_selected = m_skin_selected; + skinDlg.m_skin_width = rect.Width(); + skinDlg.m_skin_height_s = m_window_height_s; + skinDlg.m_skin_height_l = m_window_height; + if (skinDlg.DoModal() == IDOK) + { + m_skin_selected = skinDlg.m_skin_selected; + m_skin_name = m_skins[m_skin_selected]; + //뱳ͼƬ + if (m_show_cpu_memory) + m_back_img = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\background_l.bmp").c_str(), IMAGE_BITMAP, rect.Width(), m_window_height, LR_LOADFROMFILE); + else + m_back_img = (HBITMAP)LoadImage(NULL, (theApp.m_skin_path + m_skins[m_skin_selected] + L"\\background.bmp").c_str(), IMAGE_BITMAP, rect.Width(), m_window_height_s, LR_LOADFROMFILE); + SetBackgroundImage(m_back_img); + //ȡƤɫɫ + theApp.m_text_color = skinDlg.GetTextColor(); + m_disp_cpu.SetTextColor(theApp.m_text_color); + m_disp_memory.SetTextColor(theApp.m_text_color); + m_disp_up.SetTextColor(theApp.m_text_color); + m_disp_down.SetTextColor(theApp.m_text_color); + + SaveConfig(); + } +} + + + +void CTrafficMonitorDlg::OnTrafficHistory() +{ + // TODO: ڴ + CHistoryTrafficDlg historyDlg(m_history_traffics); + historyDlg.DoModal(); +} + + +void CTrafficMonitorDlg::OnMouseMove(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + m_tool_tips.SetMaxTipWidth(600); + CString tip_info; + if (m_show_cpu_memory) + { + tip_info.Format(_T("ʹ%s\r\nڴʹã%s/%s"), CCommon::KBytesToString(static_cast(theApp.m_today_traffic / 1024)), + CCommon::KBytesToString(theApp.m_used_memory), CCommon::KBytesToString(theApp.m_total_memory)); + } + else + { + tip_info.Format(_T("ʹ%s\r\nCPUʹã%d%%\r\nڴʹã%s/%s (%d%%)"), CCommon::KBytesToString(static_cast(theApp.m_today_traffic / 1024)), + theApp.m_cpu_usage, + CCommon::KBytesToString(theApp.m_used_memory), CCommon::KBytesToString(theApp.m_total_memory), + theApp.m_memory_usage); + } + m_tool_tips.AddTool(this, tip_info); + + CDialogEx::OnMouseMove(nFlags, point); +} + + +void CTrafficMonitorDlg::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // TODO: ڴϢ/Ĭֵ + OnNetworkInfo(); + CDialogEx::OnLButtonDblClk(nFlags, point); +} + + +void CTrafficMonitorDlg::OnOptions() +{ + // TODO: ڴ + _OnOptions(0); +} + + +//ͨڵҼ˵򿪡ѡԻ +void CTrafficMonitorDlg::OnOptions2() +{ + // TODO: ڴ + _OnOptions(1); +} diff --git a/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.h b/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.h new file mode 100644 index 0000000..7990814 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/TrafficMonitorDlg.h @@ -0,0 +1,212 @@ + +// TrafficMonitorDlg.h : ͷļ +// + +#pragma once +#pragma comment (lib, "iphlpapi.lib") +#include"NetworkInfoDlg.h" +#include "afxwin.h" +#include "StaticEx.h" +#include "Common.h" +#include "TaskBarDlg.h" +#include "SkinDlg.h" +#include "HistoryTrafficDlg.h" +#include "DonateDlg.h" +#include "OptionsDlg.h" + +// CTrafficMonitorDlg Ի +class CTrafficMonitorDlg : public CDialogEx +{ +// +public: + CTrafficMonitorDlg(CWnd* pParent = NULL); // ׼캯 + ~CTrafficMonitorDlg(); + +// Ի +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_TRAFFICMONITOR_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + +// ʵ +protected: + HICON m_hIcon; + CMenu m_menu; //Ҽ˵ + CMenu* m_select_connection_menu; //ѡ˵ + NOTIFYICONDATA m_ntIcon; //֪ͨͼ + CTaskBarDlg* m_tBarDlg; //ڵָ + + //Ƕ׽ṹ壬һӵϢ + struct NetWorkConection + { + int index; // + string description; // + unsigned int in_bytes; //ʼʱѽֽ + unsigned int out_bytes; //ʼʱѷֽ + NetWorkConection(int idx, string desc, unsigned int in_bytes, unsigned out_bytes) + : index{ idx }, description{ desc }, in_bytes{ in_bytes }, out_bytes{out_bytes} //캯 + {} + }; + + vector m_connections; //ȡҪʾѡ˵е + MIB_IFTABLE* m_pIfTable; + DWORD m_dwSize{}; //m_pIfTableĴС + int m_connection_selected{ 0 }; //Ҫʾӵ + bool m_auto_select{ false }; //Զѡ + unsigned int m_in_bytes; //ǰѽյֽ + unsigned int m_out_bytes; //ǰѷ͵ֽ + unsigned int m_last_in_bytes{}; //ϴѽյֽ + unsigned int m_last_out_bytes{}; //ϴѷ͵ֽ + string m_connection_name; //ǰѡ + + FILETIME m_preidleTime; + FILETIME m_prekernelTime; + FILETIME m_preuserTime; + + bool m_always_on_top{ false }; //ö + int m_transparency{ 100 }; //͸ + bool m_lock_window_pos{ false }; //λ + bool m_show_cpu_memory{ false }; //ʾCPUڴ + bool m_mouse_penetrate{ false }; //괩͸ + bool m_show_task_bar_wnd{ false }; //ʾ + //bool m_swap_up_down{ false }; //ϴʾλ + bool m_auto_run; //Ƿ񿪻Զ + wstring m_start_up_path; //ʼ˵еġļе· + + bool m_first_start{ true }; //ʼʱΪtrueڶʱһΪflase + + int m_position_x; //λõx + int m_position_y; //λõy + + int m_screen_width; //Ļ + int m_screen_height; //Ļ߶ + + int m_window_height; //ڸ߶ + int m_window_height_s; //ʾCPUڴʱĴڸ߶ + + HBITMAP m_back_img; //ͼƬ + + CStaticEx m_disp_up; //ʾϴıؼ + CStaticEx m_disp_down; //ʾصıؼ + CStaticEx m_disp_cpu; //ʾCPUʵıؼ + CStaticEx m_disp_memory; //ʾڴʵıؼ + + //COLORREF m_text_color{}; //ɫ + CFont m_font; // + //CString m_font_name; // + //int m_font_size; //С + + int m_restart_cnt{ -1 }; //³ʼ + unsigned int m_timer_cnt{}; //ʱ + int m_zero_speed_cnt{}; //ⲻ٣ñͻԼ + + static unsigned int m_WM_TASKBARCREATED; //Ϣ + + vector m_skins; //Ƥļ· + int m_skin_selected{}; //ѡƤ + wstring m_skin_name{}; //ѡƤ + + SYSTEMTIME m_start_time; //ʱʱ + + deque m_history_traffics; //ʷ + + CToolTipCtrl m_tool_tips; + + bool m_connection_change_flag{ false }; //ִйIniConnection()flagΪtrue + + bool m_cannot_save_config_warning{ true }; //ָʾǷ޷ʱʾ + + bool m_is_foreground_fullscreen{ false }; //ָʾǰ̨Ƿȫʾ + + //ʾ4Ŀǰַ + //wstring m_up_string; //ĬΪϴ: + //wstring m_down_string; //ĬΪ: + //wstring m_cpu_string; //ĬΪCPU: + //wstring m_memory_string; //ĬΪڴ: + + + void ShowInfo(); //ϴٶϢʾ + void SetTransparency(); //m_transparencyֵô͸ + void SetAlwaysOnTop(); //m_always_on_topֵôö + void SetMousePenetrate(); //m_mouse_penetrateֵǷ괩͸ + void CheckWindowPos(); //Դڵλã細ڵλĻ⣬ƶʹȫĻڣλ + void GetScreenSize(int compensition_value = 23); //ȡĻĿȺ͸߶ + + void LoadConfig(); // + void SaveConfig(); // + + void AutoSelect(); //Զѡ + void IniConnection(); //ʼ + + void CloseTaskBarWnd(); //ر + void OpenTaskBarWnd(); // + + void AddNotifyIcon(); //֪ͨͼ + void DeleteNotifyIcon(); + + void SaveHistoryTraffic(); + void LoadHistoryTraffic(); + + void _OnOptions(int tab); //򿪡ѡԻĴΪʱлıǩ + +public: + void ApplySettings(); + +protected: + // ɵϢӳ亯 + virtual BOOL OnInitDialog(); +// afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: +// afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnTimer(UINT_PTR nIDEvent); +// afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnNetworkInfo(); + afx_msg void OnAlwaysOnTop(); + afx_msg void OnUpdateAlwaysOnTop(CCmdUI *pCmdUI); + afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); + afx_msg void OnTransparency100(); + afx_msg void OnTransparency80(); + afx_msg void OnTransparency60(); + afx_msg void OnTransparency40(); + afx_msg void OnClose(); + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + afx_msg void OnInitMenu(CMenu* pMenu); + virtual BOOL PreTranslateMessage(MSG* pMsg); + afx_msg void OnLockWindowPos(); + afx_msg void OnUpdateLockWindowPos(CCmdUI *pCmdUI); + afx_msg void OnMove(int x, int y); +protected: + afx_msg LRESULT OnNotifyIcon(WPARAM wParam, LPARAM lParam); +public: + afx_msg void OnShowNotifyIcon(); + afx_msg void OnUpdateShowNotifyIcon(CCmdUI *pCmdUI); + afx_msg void OnDestroy(); + afx_msg void OnShowCpuMemory(); + afx_msg void OnUpdateShowCpuMemory(CCmdUI *pCmdUI); + afx_msg void OnMousePenetrate(); + afx_msg void OnUpdateMousePenetrate(CCmdUI *pCmdUI); + //afx_msg void OnTextColor(); + afx_msg void OnShowTaskBarWnd(); + afx_msg void OnUpdateShowTaskBarWnd(CCmdUI *pCmdUI); + afx_msg void OnAppAbout(); + afx_msg void OnShowCpuMemory2(); + afx_msg void OnAutoRunWhenStart(); + afx_msg void OnHideMainWnd(); + afx_msg void OnUpdateHideMainWnd(CCmdUI *pCmdUI); + afx_msg void OnChangeSkin(); + afx_msg void OnUpdateAutoRunWhenStart(CCmdUI *pCmdUI); + afx_msg LRESULT OnTaskBarCreated(WPARAM wParam, LPARAM lParam); + //afx_msg void OnSetFont(); + afx_msg void OnTrafficHistory(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnOptions(); + afx_msg void OnOptions2(); +}; diff --git a/src/TrafficMonitor/TrafficMonitor/config.ini b/src/TrafficMonitor/TrafficMonitor/config.ini new file mode 100644 index 0000000..4822194 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/config.ini @@ -0,0 +1,25 @@ +[config] +transparency=80 +always_on_top=0 +lock_window_pos=0 +show_notify_icon=1 +show_cpu_memory=1 +mouse_penetrate=0 +show_task_bar_wnd=1 +position_x=1830 +position_y=1316 +text_color=16384 +hide_main_window=0 +skin_selected=.\skins\0ĬƤ +swap_up_down=0 +font_name=΢ź +font_size=10 +[connection] +auto_select=1 +connection_name=Marvell AVASTAR Wireless-AC Network Controller-WFP Native MAC Layer LightWeight Filter-0000 +[task_bar] +task_bar_back_color=0 +task_bar_text_color=16777215 +tack_bar_show_cpu_memory=1 +tack_bar_font_name=΢ź +tack_bar_font_size=9 diff --git a/src/TrafficMonitor/TrafficMonitor/error.log b/src/TrafficMonitor/TrafficMonitor/error.log new file mode 100644 index 0000000..c02fc2b --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/error.log @@ -0,0 +1,181 @@ +2017/2/16 18:37:56.822: ܳ쳣³ʼӡ(ѷֽ2200ѽֽ1824ϴٶȣ-3043481ٶȣ-17311021ǰӣ(null)³ʼ0) +2017/2/16 18:38:3.824: ܳ쳣³ʼӡ(ѷֽ2200ѽֽ1824ϴٶȣ-3046948ٶȣ-17311690ǰӣ(null)³ʼ0) +2017/2/16 18:40:36.382: ܳ쳣³ʼӡ(ѷֽ2200ѽֽ1824ϴٶȣ-3188902ٶȣ-17366346ǰӣ(null)³ʼ0) +2017/2/20 22:57:36.253: ܳ쳣³ʼӡ(ѷֽ3756ѽֽ43ϴٶȣ4294099790ٶȣ4293549490ǰӣVMware Virtual Ethernet Adapter for VMnet1³ʼ1) +2017/2/20 22:58:35.256: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294058884ٶȣ4293522289ǰӣMicrosoft Teredo Tunneling Adapter³ʼ2) +2017/2/20 22:58:36.252: ܳ쳣³ʼӡ(ѷֽ7580ѽֽ3648ϴٶȣ4294058884ٶȣ4293522289ǰӣMicrosoft Teredo Tunneling Adapter³ʼ3) +2017/2/20 22:59:18.252: ܳ쳣³ʼӡ(ѷֽ2541858ѽֽ0ϴٶȣ2532782ٶȣ4294962888ǰӣBluetooth 豸()³ʼ1) +2017/2/20 23:4:51.382: ܳ쳣³ʼӡ(ѷֽ9214ѽֽ4408ϴٶȣ4292203890ٶȣ4408ǰӣMicrosoft Teredo Tunneling Adapter³ʼ1) +2017/2/20 23:5:3.383: ܳ쳣³ʼӡ(ѷֽ4132ѽֽ43ϴٶȣ4294962214ٶȣ4294962931ǰӣVMware Virtual Ethernet Adapter for VMnet1³ʼ2) +2017/2/20 23:5:12.375: ܳ쳣³ʼӡ(ѷֽ2787898ѽֽ0ϴٶȣ2783766ٶȣ4294967253ǰӣBluetooth 豸()³ʼ3) +2017/2/20 23:6:21.381: ܳ쳣³ʼӡ(ѷֽ4498ѽֽ43ϴٶȣ4292085496ٶȣ43ǰӣVMware Virtual Ethernet Adapter for VMnet1³ʼ4) +2017/2/20 23:6:26.377: ܳ쳣³ʼӡ(ѷֽ2886298ѽֽ0ϴٶȣ2881800ٶȣ4294967253ǰӣBluetooth 豸()³ʼ5) +2017/2/20 23:6:36.381: ܳ쳣³ʼӡ(ѷֽ198595ѽֽ987773ϴٶȣ4292279593ٶȣ987773ǰӣMarvell AVASTAR Wireless-AC Network Controller³ʼ6) +2017/2/20 23:6:47.382: ܳ쳣³ʼӡ(ѷֽ2886298ѽֽ0ϴٶȣ2683046ٶȣ4293973654ǰӣBluetooth 豸()³ʼ1) +2017/2/20 23:12:42.422: ܳ쳣³ʼӡ(ѷֽ4518ѽֽ45ϴٶȣ4294346264ٶȣ4293725714ǰӣVMware Virtual Ethernet Adapter for VMnet1³ʼ1) +2017/2/20 23:17:33.49: ܳ쳣³ʼӡ(ѷֽ3074534ѽֽ0ϴٶȣ2134892ٶȣ4293329376ǰӣBluetooth 豸()³ʼ1) +2017/2/20 23:17:48.54: ܳ쳣³ʼӡ(ѷֽ939642ѽֽ1637920ϴٶȣ4292823095ٶȣ1637920ǰӣMarvell AVASTAR Wireless-AC Network Controller³ʼ1) +2017/2/20 23:20:58.877: ǰѶϿ³ʼӡ(³ʼ0) +2017/2/20 23:20:59.875: ǰѶϿ³ʼӡ(³ʼ1) +2017/2/20 23:21:0.881: ǰѶϿ³ʼӡ(³ʼ2) +2017/2/20 23:21:1.874: ǰѶϿ³ʼӡ(³ʼ3) +2017/2/20 23:21:2.879: ǰѶϿ³ʼӡ(³ʼ4) +2017/2/20 23:21:3.874: ǰѶϿ³ʼӡ(³ʼ5) +2017/2/20 23:21:4.875: ǰѶϿ³ʼӡ(³ʼ6) +2017/2/20 23:21:5.892: ܳ쳣³ʼӡ(ѷֽ3247889ѽֽ0ϴٶȣ2308247ٶȣ4293329376ǰӣBluetooth 豸()³ʼ8) +2017/2/20 23:22:5.882: ǰѶϿ³ʼӡ(³ʼ8) +2017/2/20 23:22:6.902: ܳ쳣³ʼӡ(ѷֽ159277ѽֽ452466ϴٶȣ4291810367ٶȣ452466ǰӣMarvell AVASTAR Wireless-AC Network Controller³ʼ10) +2017/2/22 19:49:24.337: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ1) +2017/2/22 19:49:25.322: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ2) +2017/2/22 19:49:26.347: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ3) +2017/2/22 19:49:27.322: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ4) +2017/2/22 19:49:28.331: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ5) +2017/2/22 19:49:29.323: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ6) +2017/2/22 19:49:30.326: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ7) +2017/2/22 19:49:31.324: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ8) +2017/2/22 19:49:32.327: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ9) +2017/2/22 19:49:33.321: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ10) +2017/2/22 19:49:34.322: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4293789522ٶȣ4291789933ǰӣSoftware Loopback Interface 1³ʼ11) +2017/2/22 19:58:51.150: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ1) +2017/2/22 19:58:52.158: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ2) +2017/2/22 19:58:53.151: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ3) +2017/2/22 19:58:54.150: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ4) +2017/2/22 19:58:55.154: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ5) +2017/2/22 19:58:56.154: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ6) +2017/2/22 19:58:57.148: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth Device (RFCOMM Protocol TDI)³ʼ7) +2017/2/22 19:58:58.149: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth 豸()³ʼ8) +2017/2/22 19:58:59.150: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth 豸()³ʼ9) +2017/2/22 19:59:0.155: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth 豸()³ʼ10) +2017/2/22 19:59:1.155: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣBluetooth 豸()³ʼ11) +2017/2/22 20:0:46.159: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ1) +2017/2/22 20:0:47.154: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ2) +2017/2/22 20:0:48.152: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ3) +2017/2/22 20:0:49.156: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ4) +2017/2/22 20:0:50.155: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ5) +2017/2/22 20:0:51.162: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ6) +2017/2/22 20:0:52.151: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ7) +2017/2/22 20:0:53.167: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ8) +2017/2/22 20:0:54.151: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ9) +2017/2/22 20:0:55.150: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ10) +2017/2/22 20:0:56.158: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4291927324ٶȣ4282481481ǰӣWAN Miniport (IP)-QoS Packet Scheduler-0000³ʼ11) +2017/2/23 10:35:16.674: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 8:54:55.916: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4287175116ٶȣ4264872844ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 8:54:56.886: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4287175116ٶȣ4264872844ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 8:54:57.665: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4287175116ٶȣ4264872844ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 8:54:59.308: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4287175116ٶȣ4264872844ǰӣWAN Miniport (IPv6)³ʼ8) +2017/2/24 8:55:0.851: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4287175116ٶȣ4264872844ǰӣWAN Miniport (IPv6)³ʼ10) +2017/2/24 8:56:10.382: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 8:56:11.385: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 8:56:12.403: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ3) +2017/2/24 8:56:13.416: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 8:56:14.431: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 8:56:15.447: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 8:56:16.464: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ7) +2017/2/24 8:56:17.471: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ8) +2017/2/24 8:56:18.490: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ9) +2017/2/24 8:56:19.496: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ10) +2017/2/24 8:57:40.489: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 8:57:40.504: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ3) +2017/2/24 8:57:41.3: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 8:57:42.17: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 8:57:43.31: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 8:57:44.45: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294783399ٶȣ4294592993ǰӣWAN Miniport (IPv6)³ʼ7) +2017/2/24 8:58:18.143: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 8:58:20.180: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 8:58:24.523: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ3) +2017/2/24 8:58:24.539: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 8:58:25.319: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 8:58:26.336: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 8:58:27.350: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ7) +2017/2/24 8:58:28.364: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ8) +2017/2/24 9:1:46.830: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 9:1:47.848: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 9:1:48.865: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ3) +2017/2/24 9:1:49.873: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 9:1:50.887: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 9:1:51.904: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 9:1:52.915: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ7) +2017/2/24 9:1:53.929: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ8) +2017/2/24 9:1:54.944: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ9) +2017/2/24 9:1:55.963: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ10) +2017/2/24 9:1:56.977: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ11) +2017/2/24 9:9:59.817: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 9:10:1.128: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ2) +2017/2/24 9:10:2.406: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ3) +2017/2/24 9:10:3.627: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ4) +2017/2/24 9:10:4.918: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 9:10:9.267: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 9:14:33.111: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣWAN Miniport (IPv6)³ʼ1) +2017/2/24 9:16:40.93: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ0ٶȣ0ǰӣIntel(R) Ethernet Connection I217-LM-TM NDIS Sample LightWeight Filter-0000³ʼ3) +2017/2/24 9:17:3.706: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294828536ٶȣ4294667153ǰӣWAN Miniport (IPv6)³ʼ5) +2017/2/24 9:17:11.146: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294828536ٶȣ4294667153ǰӣWAN Miniport (IPv6)³ʼ6) +2017/2/24 9:17:28.382: ܳ쳣³ʼӡ(ѷֽ0ѽֽ0ϴٶȣ4294828536ٶȣ4294667153ǰӣIntel(R) Ethernet Connection I217-LM-TM NDIS Sample LightWeight Filter-0000³ʼ8) +2017/2/24 9:17:36.778: ܳ쳣³ʼӡ(ѷֽ8479ѽֽ0ϴٶȣ4294828536ٶȣ4294667153ǰӣIntel(R) Ethernet Connection I217-LM-TM NDIS Sample LightWeight Filter-0000³ʼ9) +2017/3/1 16:10:37.34: ⵽仯»ȡӡǰ94 +2017/3/1 16:13:4.15: ⵽仯»ȡӡǰ43 +2017/3/1 16:13:12.928: ⵽仯»ȡӡǰ39 +2017/3/1 16:13:57.928: ⵽仯»ȡӡǰ94 +2017/3/1 16:13:58.931: ⵽仯»ȡӡǰ43 +2017/3/1 16:14:19.926: ⵽仯»ȡӡǰ39 +2017/4/23 20:26:13.635: ⵽仯»ȡӡǰ61(³ʼ1) +2017/4/23 20:28:2.97: ⵽仯»ȡӡǰ16(³ʼ1) +2017/4/23 20:28:33.475: ⵽仯»ȡӡǰ61(³ʼ2) +2017/4/23 20:28:44.850: ⵽仯»ȡӡǰ16(³ʼ3) +2017/5/10 20:36:5.182: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ1) +2017/5/10 20:36:9.182: ⵽仯»ȡӡǰ72(³ʼ2) +2017/5/10 20:36:52.186: ⵽仯»ȡӡǰ27(³ʼ3) +2017/5/19 19:14:7.512: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 19:17:4.412: ⵽仯»ȡӡǰ49(³ʼ1) +2017/5/19 19:17:10.327: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 19:17:34.326: ⵽仯»ȡӡǰ94(³ʼ3) +2017/5/19 19:17:35.318: ⵽仯»ȡӡǰ43(³ʼ4) +2017/5/19 19:17:40.320: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ5) +2017/5/19 19:17:46.326: ⵽仯»ȡӡǰ39(³ʼ6) +2017/5/19 19:17:51.340: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ7) +2017/5/19 19:31:12.632: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 19:31:20.978: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 19:31:23.630: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ3) +2017/5/19 19:31:24.637: ⵽仯»ȡӡǰ49(³ʼ4) +2017/5/19 19:43:29.346: ⵽仯»ȡӡǰ93(³ʼ1) +2017/5/19 19:48:49.208: ⵽仯»ȡӡǰ93(³ʼ1) +2017/5/19 19:48:54.218: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 19:48:59.265: ⵽仯»ȡӡǰ39(³ʼ3) +2017/5/19 19:49:5.208: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ4) +2017/5/19 19:55:29.208: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 19:55:30.212: ⵽仯»ȡӡǰ43(³ʼ2) +2017/5/19 19:55:35.220: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ3) +2017/5/19 19:55:47.209: ⵽仯»ȡӡǰ39(³ʼ4) +2017/5/19 19:55:52.212: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ5) +2017/5/19 19:58:26.851: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 19:58:31.844: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 19:58:32.847: ⵽仯»ȡӡǰ43(³ʼ3) +2017/5/19 20:2:2.894: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 20:2:3.894: ⵽仯»ȡӡǰ43(³ʼ2) +2017/5/19 20:2:9.818: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ3) +2017/5/19 20:2:9.836: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ4) +2017/5/19 20:2:10.944: ⵽仯»ȡӡǰ39(³ʼ5) +2017/5/19 20:3:40.320: ⵽仯»ȡӡǰ94(³ʼ1) +2017/5/19 20:3:41.319: ⵽仯»ȡӡǰ43(³ʼ2) +2017/5/19 20:3:45.986: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ3) +2017/5/19 20:3:46.3: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ4) +2017/5/19 20:3:47.341: ⵽仯»ȡӡǰ39(³ʼ5) +2017/5/19 20:19:6.75: ⵽仯»ȡӡǰ93(³ʼ1) +2017/5/19 20:19:10.905: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 20:19:10.921: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ3) +2017/5/19 20:19:12.188: ⵽仯»ȡӡǰ39(³ʼ4) +2017/5/19 20:24:9.238: ⵽仯»ȡӡǰ93(³ʼ1) +2017/5/19 20:24:14.234: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 20:25:37.853: ⵽仯»ȡӡǰ93(³ʼ1) +2017/5/19 20:25:46.21: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ2) +2017/5/19 20:26:16.323: ⵽仯»ȡӡǰ39(³ʼ3) +2017/5/19 20:26:26.164: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ4) +2017/5/19 20:26:36.903: ⵽仯»ȡӡǰ93(³ʼ5) +2017/5/19 20:26:41.251: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ6) +2017/5/19 20:26:43.253: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ7) +2017/5/19 20:26:44.334: ⵽仯»ȡӡǰ39(³ʼ8) +2017/5/19 20:26:52.258: ⵽仯»ȡӡǰ94(³ʼ9) +2017/5/19 20:26:53.254: ⵽仯»ȡӡǰ43(³ʼ10) +2017/5/19 20:26:56.253: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ11) +2017/5/19 20:26:58.734: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ12) +2017/5/19 20:26:58.740: ܳ쳣ǰѡӺӲһ£»ȡӡ(³ʼ13) +2017/5/19 20:27:0.261: ⵽仯»ȡӡǰ39(³ʼ14) diff --git a/src/TrafficMonitor/TrafficMonitor/history_traffic - 副本.dat b/src/TrafficMonitor/TrafficMonitor/history_traffic - 副本.dat new file mode 100644 index 0000000..6730f5d --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/history_traffic - 副本.dat @@ -0,0 +1,24 @@ +2017/05/29 24958 +2017/05/29 2000 +2017/05/25 16310 +2017/05/25 33 +2017/05/21 148 +2017/05/20 1182 +2017/05/19 777 +2017/05/19 11 +2017/05/18 6196 +2017/05/17 8691 +2017/05/16 4263 +2017/05/15 4097 +2017/05/14 8 +2017/05/14 43 +2017/05/13 107 +2017/05/13 56221 +2017/05/11 15722 +2017/05/10 6596 +2017/05/04 456 +2017/05/02 123 +2017/05/02 11 +2017/04/21 66 +2017/03/14 32 +2017/03/14 22 \ No newline at end of file diff --git a/src/TrafficMonitor/TrafficMonitor/history_traffic.dat b/src/TrafficMonitor/TrafficMonitor/history_traffic.dat new file mode 100644 index 0000000..46d4cbf --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/history_traffic.dat @@ -0,0 +1,20 @@ +2017/06/25 0 +2017/06/04 10 +2017/05/30 263 +2017/05/29 58447 +2017/05/25 16343 +2017/05/21 148 +2017/05/20 1182 +2017/05/19 788 +2017/05/18 6196 +2017/05/17 8691 +2017/05/16 4263 +2017/05/15 4097 +2017/05/14 51 +2017/05/13 56328 +2017/05/11 15722 +2017/05/10 6596 +2017/05/04 456 +2017/05/02 134 +2017/04/21 66 +2017/03/14 54 diff --git a/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.ico b/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.ico new file mode 100644 index 0000000..8d08bb3 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.ico differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.rc2 b/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.rc2 new file mode 100644 index 0000000..9867a83 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/TrafficMonitor.rc2 differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/about_background.bmp b/src/TrafficMonitor/TrafficMonitor/res/about_background.bmp new file mode 100644 index 0000000..dbb10c3 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/about_background.bmp differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/bitmap1.bmp b/src/TrafficMonitor/TrafficMonitor/res/bitmap1.bmp new file mode 100644 index 0000000..6e8e840 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/bitmap1.bmp differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/donate.bmp b/src/TrafficMonitor/TrafficMonitor/res/donate.bmp new file mode 100644 index 0000000..489fd8f Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/donate.bmp differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/notifyicon - 副本 (2).ico b/src/TrafficMonitor/TrafficMonitor/res/notifyicon - 副本 (2).ico new file mode 100644 index 0000000..db18962 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/notifyicon - 副本 (2).ico differ diff --git a/src/TrafficMonitor/TrafficMonitor/res/notifyicon.ico b/src/TrafficMonitor/TrafficMonitor/res/notifyicon.ico new file mode 100644 index 0000000..b9864f9 Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/res/notifyicon.ico differ diff --git a/src/TrafficMonitor/TrafficMonitor/resource.h b/src/TrafficMonitor/TrafficMonitor/resource.h new file mode 100644 index 0000000..7bc900a Binary files /dev/null and b/src/TrafficMonitor/TrafficMonitor/resource.h differ diff --git a/src/TrafficMonitor/TrafficMonitor/stdafx.cpp b/src/TrafficMonitor/TrafficMonitor/stdafx.cpp new file mode 100644 index 0000000..83b08c4 --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/stdafx.cpp @@ -0,0 +1,8 @@ + +// stdafx.cpp : ֻ׼ļԴļ +// TrafficMonitor.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + + diff --git a/src/TrafficMonitor/TrafficMonitor/stdafx.h b/src/TrafficMonitor/TrafficMonitor/stdafx.h new file mode 100644 index 0000000..a90ac1a --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/stdafx.h @@ -0,0 +1,72 @@ + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +// ر MFC ijЩɷĺԵľϢ +#define _AFX_ALL_WARNINGS + +#include // MFC ͱ׼ +#include // MFC չ + + +#include // MFC Զ + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // Ϳؼ MFC ֧ + + +#include +using std::string; +using std::wstring; +#include +using std::vector; +#include +using std::deque; +#include +#include +using std::ifstream; +using std::ofstream; +#include +#include + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + +#define MY_WM_NOTIFYICON (WM_USER+1001) + +//#define CONFIG_PATH _T(".\\config.ini") +//#define CONFIG_PATHA ".\\config.ini" +//#define LOG_PATH _T(".\\error.log") +//#define HISTORY_TRAFFIC_PATH _T(".\\history_traffic.dat") +#define MAX_RESTART_CNT 10 //³ʼ + +#define MAIN_TIMER 1234 //ʱID +#define DELAY_TIMER 1235 //ʱʱID diff --git a/src/TrafficMonitor/TrafficMonitor/targetver.h b/src/TrafficMonitor/TrafficMonitor/targetver.h new file mode 100644 index 0000000..416cebf --- /dev/null +++ b/src/TrafficMonitor/TrafficMonitor/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/src/snatshot.png b/src/snatshot.png deleted file mode 100644 index c294714..0000000 Binary files a/src/snatshot.png and /dev/null differ