├── TrafficMonitor ├── skins │ ├── 0默认皮肤 │ │ ├── skin.ini │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ ├── background_mask.bmp │ │ └── background_mask_l.bmp │ ├── 皮肤01 │ │ ├── skin.ini │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ ├── background_mask.bmp │ │ └── background_mask_l.bmp │ ├── 皮肤02 │ │ ├── skin.ini │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ ├── background_mask.bmp │ │ └── background_mask_l.bmp │ ├── 皮肤03 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤04 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤05 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤06 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤07 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤08 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤09 │ │ ├── skin.ini │ │ ├── background.bmp │ │ └── background_l.bmp │ ├── 皮肤10 │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ └── skin.ini │ ├── 皮肤11 │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ └── skin.ini │ ├── 默认皮肤2 │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ ├── background_mask.bmp │ │ ├── background_mask_l.bmp │ │ └── skin.ini │ ├── xml_test │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ └── skin.xml │ └── 皮肤10(竖排) │ │ ├── background.bmp │ │ ├── background_l.bmp │ │ └── skin.ini ├── WIC.h ├── WIC.cpp ├── CPUUsage.h ├── SpinEdit.h ├── StaticEx.h ├── resource.h ├── stdafx.cpp ├── CPUUsage.cpp ├── CTabCtrlEx.h ├── LinkStatic.h ├── ListCtrlEx.h ├── SimpleXML.cpp ├── SimpleXML.h ├── StaticEx.cpp ├── crashtool.h ├── targetver.h ├── AdapterCommon.h ├── LinkStatic.cpp ├── ListCtrlEx.cpp ├── PictureStatic.h ├── res │ ├── bitmap1.bmp │ ├── bitmap3.bmp │ ├── donate.bmp │ ├── notifyicon.ico │ ├── notifyicon2.ico │ ├── notifyicon3.ico │ ├── notifyicon4.ico │ ├── notifyicon5.ico │ ├── Acknowledgement.txt │ ├── TrafficMonitor.ico │ ├── TrafficMonitor.rc2 │ ├── donate_wechart.bmp │ ├── menu_icon │ │ ├── close.ico │ │ ├── exit.ico │ │ ├── help.ico │ │ ├── info.ico │ │ ├── item.ico │ │ ├── lock.ico │ │ ├── more.ico │ │ ├── mouse.ico │ │ ├── pin.ico │ │ ├── skn.ico │ │ ├── notify.ico │ │ ├── plugins.ico │ │ ├── setting.ico │ │ ├── connection.ico │ │ ├── function.ico │ │ ├── statistics.ico │ │ ├── main_window.ico │ │ ├── task_manager.ico │ │ └── taskbar_window.ico │ ├── notify_preview.bmp │ ├── Acknowledgement_en.txt │ ├── about_background_hd.bmp │ └── notify_preview_light.bmp ├── AdapterCommon.cpp ├── CalendarHelper.h ├── DrawCommonEx.cpp ├── PictureStatic.cpp ├── TrafficMonitor.rc ├── HistoryTrafficFile.h ├── ColorSettingListCtrl.h ├── HistoryTrafficFile.cpp ├── HistoryTrafficListDlg.h ├── WindowsSettingHelper.h ├── print_compile_time.bat ├── HistoryTrafficListCtrl.h ├── HistoryTrafficCalendarDlg.h ├── auto_start_helper.h ├── DrawCommonEx.h ├── Test.h ├── ComboBox2.h ├── CMFCColorDialogEx.h ├── CVariant.h ├── TrafficMonitor.vcxproj.user ├── DonateDlg.h ├── TinyXml2Helper.h ├── WinVersionHelper.h ├── AppAlreadyRuningDlg.h ├── FilePathHelper.h ├── CSkinPreviewView.h ├── SelectConnectionsDlg.h ├── ComboBox2.cpp ├── CAutoAdaptSettingsDlg.h ├── DCompositionSupport.h ├── TaskbarDefaultStyle.h ├── MainWndColorDlg.h ├── UpdateHelper.h ├── DCompositionSupport.cpp ├── TaskbarColorDlg.h ├── DisplayTextSettingDlg.h ├── ColorStatic.h ├── SupportedRenderEnums.h ├── TabDlg.h ├── HistoryTrafficDlg.h ├── OptionsDlg.h ├── CMFCColorDialogEx.cpp ├── CVariant.cpp ├── BaseDialog.h ├── DllFunctions.cpp ├── MessageDlg.h ├── IconSelectDlg.h ├── CSkinPreviewView.cpp ├── D2D1Support.h ├── DrawCommonFactory.cpp ├── SkinDlg.h ├── CalendarHelper.cpp ├── AboutDlg.h ├── PluginInfoDlg.h ├── HighResolutionTimer.h ├── PluginManagerDlg.h ├── SpinEdit.cpp ├── HResultException.h ├── Dxgi1Support2.h ├── Test.cpp ├── SetItemOrderDlg.h ├── TinyXml2Helper.cpp ├── AppAlreadyRuningDlg.cpp ├── SupportedRenderEnums.cpp ├── TaskbarItemOrderHelper.h ├── NetworkInfoDlg.h ├── PluginManager.h ├── ReadMe.txt ├── Dxgi1Support2.cpp ├── IDrawCommon.h ├── WinVersionHelper.cpp ├── DonateDlg.cpp ├── DrawTextManager.cpp ├── DrawCommonFactory.h ├── SelectConnectionsDlg.cpp ├── MainWndSettingsDlg.h ├── HResultException.cpp ├── CTabCtrlEx.cpp ├── WindowsSettingHelper.cpp ├── CAutoAdaptSettingsDlg.cpp ├── IniHelper.h ├── MainWndColorDlg.cpp ├── HistoryTrafficListCtrl.cpp ├── FilePathHelper.cpp ├── DllFunctions.h ├── TaskbarColorDlg.cpp └── D2D1Support.cpp ├── version.info ├── Screenshots ├── main.png ├── main1.png ├── option.jpg ├── skins.PNG ├── taskbar.PNG ├── en_us │ ├── main.png │ ├── main1.png │ ├── option.jpg │ ├── taskbar.png │ ├── selecte_skin.png │ └── taskbar_item_settings.png ├── images │ ├── item.png │ ├── image1.jpg │ ├── image2.jpg │ ├── image3.jpg │ ├── image-20221119093529479.png │ ├── image-20221119093547649.png │ ├── image-20221119094324759.png │ └── image-20221119094501312.png ├── selecte_skin.png └── taskbar_item_settings.png ├── PluginDemo ├── PluginDemo.rc ├── pch.cpp ├── pch.h ├── PluginSystemDate.h ├── PluginSystemTime.h ├── OptionsDlg.h ├── CustomDrawItem.h ├── PluginSystemDate.cpp ├── DataManager.h ├── resource.h ├── PluginSystemTime.cpp ├── framework.h ├── PluginDemo.h ├── OptionsDlg.cpp ├── DataManager.cpp ├── PluginDemo.vcxproj.filters ├── CustomDrawItem.cpp └── PluginDemo.cpp ├── OpenHardwareMonitorApi ├── app.rc ├── Stdafx.cpp ├── Stdafx.h ├── resource.h ├── LibreHardwareMonitorLib.dll ├── UpdateVisitor.h ├── UpdateVisitor.cpp ├── ReadMe.txt ├── OpenHardwareMonitorApi.vcxproj.filters └── OpenHardwareMonitorImp.h ├── 皮肤制作教程.md ├── include └── OpenHardwareMonitor │ ├── OpenHardwareMonitorGlobal.h │ └── OpenHardwareMonitorApi.h ├── LICENSE_CN ├── version_utf8.info ├── LICENSE └── .github └── workflows └── main.yml /TrafficMonitor/skins/0默认皮肤/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16384 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤01/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=3803808 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤02/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=9844741 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤03/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16777215 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤04/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16777215 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤05/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=335674 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤06/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16773870 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤07/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=14547455 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤08/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16763528 3 | skin_author=zy -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤09/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16384 3 | skin_author=zy -------------------------------------------------------------------------------- /version.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/version.info -------------------------------------------------------------------------------- /Screenshots/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/main.png -------------------------------------------------------------------------------- /TrafficMonitor/WIC.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/WIC.h -------------------------------------------------------------------------------- /Screenshots/main1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/main1.png -------------------------------------------------------------------------------- /Screenshots/option.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/option.jpg -------------------------------------------------------------------------------- /Screenshots/skins.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/skins.PNG -------------------------------------------------------------------------------- /Screenshots/taskbar.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/taskbar.PNG -------------------------------------------------------------------------------- /TrafficMonitor/WIC.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/WIC.cpp -------------------------------------------------------------------------------- /PluginDemo/PluginDemo.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/PluginDemo/PluginDemo.rc -------------------------------------------------------------------------------- /PluginDemo/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: 与预编译标头对应的源文件 2 | 3 | #include "pch.h" 4 | 5 | // 当使用预编译的头时,需要使用此源文件,编译才能成功。 6 | -------------------------------------------------------------------------------- /TrafficMonitor/CPUUsage.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/CPUUsage.h -------------------------------------------------------------------------------- /TrafficMonitor/SpinEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/SpinEdit.h -------------------------------------------------------------------------------- /TrafficMonitor/StaticEx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/StaticEx.h -------------------------------------------------------------------------------- /TrafficMonitor/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/resource.h -------------------------------------------------------------------------------- /TrafficMonitor/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/stdafx.cpp -------------------------------------------------------------------------------- /Screenshots/en_us/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/main.png -------------------------------------------------------------------------------- /Screenshots/en_us/main1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/main1.png -------------------------------------------------------------------------------- /Screenshots/en_us/option.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/option.jpg -------------------------------------------------------------------------------- /Screenshots/images/item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/item.png -------------------------------------------------------------------------------- /Screenshots/selecte_skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/selecte_skin.png -------------------------------------------------------------------------------- /TrafficMonitor/CPUUsage.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/CPUUsage.cpp -------------------------------------------------------------------------------- /TrafficMonitor/CTabCtrlEx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/CTabCtrlEx.h -------------------------------------------------------------------------------- /TrafficMonitor/LinkStatic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/LinkStatic.h -------------------------------------------------------------------------------- /TrafficMonitor/ListCtrlEx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/ListCtrlEx.h -------------------------------------------------------------------------------- /TrafficMonitor/SimpleXML.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/SimpleXML.cpp -------------------------------------------------------------------------------- /TrafficMonitor/SimpleXML.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/SimpleXML.h -------------------------------------------------------------------------------- /TrafficMonitor/StaticEx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/StaticEx.cpp -------------------------------------------------------------------------------- /TrafficMonitor/crashtool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/crashtool.h -------------------------------------------------------------------------------- /TrafficMonitor/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/targetver.h -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/app.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/OpenHardwareMonitorApi/app.rc -------------------------------------------------------------------------------- /Screenshots/en_us/taskbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/taskbar.png -------------------------------------------------------------------------------- /Screenshots/images/image1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image1.jpg -------------------------------------------------------------------------------- /Screenshots/images/image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image2.jpg -------------------------------------------------------------------------------- /Screenshots/images/image3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image3.jpg -------------------------------------------------------------------------------- /TrafficMonitor/AdapterCommon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/AdapterCommon.h -------------------------------------------------------------------------------- /TrafficMonitor/LinkStatic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/LinkStatic.cpp -------------------------------------------------------------------------------- /TrafficMonitor/ListCtrlEx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/ListCtrlEx.cpp -------------------------------------------------------------------------------- /TrafficMonitor/PictureStatic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/PictureStatic.h -------------------------------------------------------------------------------- /TrafficMonitor/res/bitmap1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/bitmap1.bmp -------------------------------------------------------------------------------- /TrafficMonitor/res/bitmap3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/bitmap3.bmp -------------------------------------------------------------------------------- /TrafficMonitor/res/donate.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/donate.bmp -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/Stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/OpenHardwareMonitorApi/Stdafx.cpp -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/Stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/OpenHardwareMonitorApi/Stdafx.h -------------------------------------------------------------------------------- /TrafficMonitor/AdapterCommon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/AdapterCommon.cpp -------------------------------------------------------------------------------- /TrafficMonitor/CalendarHelper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/CalendarHelper.h -------------------------------------------------------------------------------- /TrafficMonitor/DrawCommonEx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/DrawCommonEx.cpp -------------------------------------------------------------------------------- /TrafficMonitor/PictureStatic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/PictureStatic.cpp -------------------------------------------------------------------------------- /TrafficMonitor/TrafficMonitor.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/TrafficMonitor.rc -------------------------------------------------------------------------------- /TrafficMonitor/res/notifyicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notifyicon.ico -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /Screenshots/en_us/selecte_skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/selecte_skin.png -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficFile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/HistoryTrafficFile.h -------------------------------------------------------------------------------- /TrafficMonitor/res/notifyicon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notifyicon2.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/notifyicon3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notifyicon3.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/notifyicon4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notifyicon4.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/notifyicon5.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notifyicon5.ico -------------------------------------------------------------------------------- /Screenshots/taskbar_item_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/taskbar_item_settings.png -------------------------------------------------------------------------------- /TrafficMonitor/ColorSettingListCtrl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/ColorSettingListCtrl.h -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficFile.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/HistoryTrafficFile.cpp -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficListDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/HistoryTrafficListDlg.h -------------------------------------------------------------------------------- /TrafficMonitor/WindowsSettingHelper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/WindowsSettingHelper.h -------------------------------------------------------------------------------- /TrafficMonitor/print_compile_time.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/print_compile_time.bat -------------------------------------------------------------------------------- /TrafficMonitor/res/Acknowledgement.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/Acknowledgement.txt -------------------------------------------------------------------------------- /TrafficMonitor/res/TrafficMonitor.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/TrafficMonitor.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/TrafficMonitor.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/TrafficMonitor.rc2 -------------------------------------------------------------------------------- /TrafficMonitor/res/donate_wechart.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/donate_wechart.bmp -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/close.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/close.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/exit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/exit.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/help.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/help.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/info.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/info.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/item.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/item.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/lock.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/lock.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/more.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/more.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/mouse.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/mouse.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/pin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/pin.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/skn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/skn.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/notify_preview.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notify_preview.bmp -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficListCtrl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/HistoryTrafficListCtrl.h -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/notify.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/notify.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/plugins.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/plugins.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/setting.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/setting.ico -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤01/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤01/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤02/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤02/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤03/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤03/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤04/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤04/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤05/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤05/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤06/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤06/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤07/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤07/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤08/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤08/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤09/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤09/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤10/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤11/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤11/background.bmp -------------------------------------------------------------------------------- /Screenshots/en_us/taskbar_item_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/en_us/taskbar_item_settings.png -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficCalendarDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/HistoryTrafficCalendarDlg.h -------------------------------------------------------------------------------- /TrafficMonitor/res/Acknowledgement_en.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/Acknowledgement_en.txt -------------------------------------------------------------------------------- /TrafficMonitor/res/about_background_hd.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/about_background_hd.bmp -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/connection.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/connection.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/function.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/function.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/statistics.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/statistics.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/notify_preview_light.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/notify_preview_light.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/0默认皮肤/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/0默认皮肤/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/0默认皮肤/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/0默认皮肤/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤01/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤01/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤02/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤02/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤03/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤03/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤04/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤04/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤05/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤05/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤06/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤06/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤07/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤07/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤08/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤08/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤09/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤09/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤10/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤11/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤11/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/默认皮肤2/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/默认皮肤2/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/默认皮肤2/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/默认皮肤2/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/main_window.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/main_window.ico -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/task_manager.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/task_manager.ico -------------------------------------------------------------------------------- /TrafficMonitor/skins/xml_test/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/xml_test/background.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤01/background_mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤01/background_mask.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤02/background_mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤02/background_mask.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10(竖排)/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤10(竖排)/background.bmp -------------------------------------------------------------------------------- /Screenshots/images/image-20221119093529479.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image-20221119093529479.png -------------------------------------------------------------------------------- /Screenshots/images/image-20221119093547649.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image-20221119093547649.png -------------------------------------------------------------------------------- /Screenshots/images/image-20221119094324759.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image-20221119094324759.png -------------------------------------------------------------------------------- /Screenshots/images/image-20221119094501312.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/Screenshots/images/image-20221119094501312.png -------------------------------------------------------------------------------- /TrafficMonitor/res/menu_icon/taskbar_window.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/res/menu_icon/taskbar_window.ico -------------------------------------------------------------------------------- /TrafficMonitor/skins/0默认皮肤/background_mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/0默认皮肤/background_mask.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/0默认皮肤/background_mask_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/0默认皮肤/background_mask_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/xml_test/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/xml_test/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤01/background_mask_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤01/background_mask_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤02/background_mask_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤02/background_mask_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10(竖排)/background_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/皮肤10(竖排)/background_l.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/默认皮肤2/background_mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/默认皮肤2/background_mask.bmp -------------------------------------------------------------------------------- /TrafficMonitor/skins/默认皮肤2/background_mask_l.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/TrafficMonitor/skins/默认皮肤2/background_mask_l.bmp -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/LibreHardwareMonitorLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devCKVargas/TrafficMonitor/HEAD/OpenHardwareMonitorApi/LibreHardwareMonitorLib.dll -------------------------------------------------------------------------------- /皮肤制作教程.md: -------------------------------------------------------------------------------- 1 | **皮肤制作教程已经移至Wiki页面:** 2 | 3 | [皮肤制作教程 · zhongyang219/TrafficMonitor Wiki (github.com)](https://github.com/zhongyang219/TrafficMonitor/wiki/皮肤制作教程) 4 | 5 | -------------------------------------------------------------------------------- /TrafficMonitor/auto_start_helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool is_auto_start_task_active_for_this_user(std::wstring* path); 4 | bool create_auto_start_task_for_this_user(bool runElevated); 5 | bool delete_auto_start_task_for_this_user(); 6 | -------------------------------------------------------------------------------- /include/OpenHardwareMonitor/OpenHardwareMonitorGlobal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef OPENHARDWAREMONITOR_EXPORTS 4 | #define OPENHARDWAREMONITOR_API __declspec(dllexport) 5 | #else 6 | #define OPENHARDWAREMONITOR_API __declspec(dllimport) 7 | #endif 8 | -------------------------------------------------------------------------------- /TrafficMonitor/DrawCommonEx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CDrawCommonEx 3 | { 4 | public: 5 | CDrawCommonEx(CDC* pDC); 6 | ~CDrawCommonEx(); 7 | 8 | void DrawWindowText(CRect rect, LPCTSTR str, COLORREF color); 9 | void SetFont(CFont* pFont); 10 | 11 | private: 12 | HTHEME hThm; 13 | CFont* m_pFont{}; 14 | CDC* m_pDC{}; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /PluginDemo/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: 这是预编译标头文件。 2 | // 下方列出的文件仅编译一次,提高了将来生成的生成性能。 3 | // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 4 | // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 5 | // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // 添加要在此处预编译的标头 11 | #include "framework.h" 12 | 13 | #include "resource.h" 14 | 15 | #endif //PCH_H 16 | -------------------------------------------------------------------------------- /TrafficMonitor/Test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CTest 3 | { 4 | public: 5 | CTest(); 6 | ~CTest(); 7 | 8 | static void Test(); 9 | static void TestCommand(); 10 | 11 | private: 12 | static void TestHttpQequest(); 13 | static void TestGetLicense(); 14 | static void TestSkin(); 15 | static void TestCrash(); 16 | static void TestPlugin(); 17 | static void TestDate(); 18 | }; 19 | -------------------------------------------------------------------------------- /TrafficMonitor/ComboBox2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CComboBox2 5 | 6 | class CComboBox2 : public CComboBox 7 | { 8 | DECLARE_DYNAMIC(CComboBox2) 9 | 10 | public: 11 | CComboBox2(); 12 | virtual ~CComboBox2(); 13 | void SetMouseWheelEnable(bool enable); //设置是否允许响应鼠标滚轮 14 | 15 | private: 16 | bool m_mouse_wheel_enable{ true }; 17 | 18 | protected: 19 | DECLARE_MESSAGE_MAP() 20 | public: 21 | virtual BOOL PreTranslateMessage(MSG* pMsg); 22 | }; 23 | 24 | 25 | -------------------------------------------------------------------------------- /TrafficMonitor/CMFCColorDialogEx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CMFCColorDialogEx 5 | 6 | class CMFCColorDialogEx : public CMFCColorDialog 7 | { 8 | //DECLARE_DYNAMIC(CMFCColorDialogEx) 9 | 10 | public: 11 | CMFCColorDialogEx(COLORREF clrInit = 0, DWORD dwFlags = 0 /* reserved */, CWnd* pParentWnd = NULL, HPALETTE hPal = NULL); 12 | virtual ~CMFCColorDialogEx(); 13 | 14 | protected: 15 | DECLARE_MESSAGE_MAP() 16 | 17 | virtual BOOL OnInitDialog(); 18 | 19 | }; 20 | 21 | 22 | -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/UpdateVisitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using namespace LibreHardwareMonitor::Hardware; 4 | 5 | namespace OpenHardwareMonitorApi 6 | { 7 | public ref class UpdateVisitor : IVisitor 8 | { 9 | public: 10 | virtual void VisitComputer(IComputer^ computer); 11 | virtual void VisitHardware(IHardware^ hardware); 12 | virtual void VisitSensor(ISensor^ sensor); 13 | virtual void VisitParameter(IParameter^ parameter); 14 | }; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /TrafficMonitor/CVariant.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CVariant 3 | { 4 | public: 5 | CVariant(int value); 6 | CVariant(size_t value); 7 | CVariant(double value); 8 | CVariant(LPCTSTR value); 9 | CVariant(const CString& value); 10 | CVariant(const wstring& value); 11 | 12 | ~CVariant(); 13 | 14 | CString ToString() const; 15 | 16 | private: 17 | enum class eType { INT, UINT, DOUBLE, STRING }; 18 | 19 | int m_value_int; 20 | double m_value_double; 21 | CString m_value_string; 22 | eType m_type; 23 | 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /PluginDemo/PluginSystemDate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | 4 | class CPluginSystemDate : public IPluginItem 5 | { 6 | public: 7 | CPluginSystemDate(); 8 | 9 | // 通过 IPluginItem 继承 10 | virtual const wchar_t* GetItemName() const override; 11 | virtual const wchar_t* GetItemId() const override; 12 | virtual const wchar_t* GetItemLableText() const override; 13 | virtual const wchar_t* GetItemValueText() const override; 14 | virtual const wchar_t* GetItemValueSampleText() const override; 15 | 16 | private: 17 | }; 18 | -------------------------------------------------------------------------------- /PluginDemo/PluginSystemTime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | 4 | class CPluginSystemTime : public IPluginItem 5 | { 6 | public: 7 | CPluginSystemTime(); 8 | 9 | public: 10 | // 通过 IPluginItem 继承 11 | virtual const wchar_t* GetItemName() const override; 12 | virtual const wchar_t* GetItemId() const override; 13 | virtual const wchar_t* GetItemLableText() const override; 14 | virtual const wchar_t* GetItemValueText() const override; 15 | virtual const wchar_t* GetItemValueSampleText() const override; 16 | 17 | private: 18 | }; 19 | -------------------------------------------------------------------------------- /PluginDemo/OptionsDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataManager.h" 3 | 4 | // COptionsDlg 对话框 5 | 6 | class COptionsDlg : public CDialog 7 | { 8 | DECLARE_DYNAMIC(COptionsDlg) 9 | 10 | public: 11 | COptionsDlg(CWnd* pParent = nullptr); // 标准构造函数 12 | virtual ~COptionsDlg(); 13 | 14 | // 对话框数据 15 | #ifdef AFX_DESIGN_TIME 16 | enum { IDD = IDD_OPTIONS_DIALOG }; 17 | #endif 18 | 19 | SettingData m_data; 20 | 21 | protected: 22 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 23 | 24 | DECLARE_MESSAGE_MAP() 25 | public: 26 | virtual BOOL OnInitDialog(); 27 | afx_msg void OnBnClickedShowSecondCheck(); 28 | }; 29 | -------------------------------------------------------------------------------- /PluginDemo/CustomDrawItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | 4 | class CCustomDrawItem : public IPluginItem 5 | { 6 | // 通过 IPluginItem 继承 7 | virtual const wchar_t* GetItemName() const override; 8 | virtual const wchar_t* GetItemId() const override; 9 | virtual const wchar_t* GetItemLableText() const override; 10 | virtual const wchar_t* GetItemValueText() const override; 11 | virtual const wchar_t* GetItemValueSampleText() const override; 12 | virtual bool IsCustomDraw() const override; 13 | virtual int GetItemWidth() const override; 14 | virtual void DrawItem(void* hDC, int x, int y, int w, int h, bool dark_mode) override; 15 | }; 16 | -------------------------------------------------------------------------------- /TrafficMonitor/skins/默认皮肤2/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16384 3 | skin_author=zy 4 | [layout] 5 | text_height=20 6 | width_l=220 7 | height_l=43 8 | up_x_l=6 9 | up_y_l=2 10 | up_width_l=108 11 | down_x_l=114 12 | down_y_l=2 13 | down_width_l=110 14 | cpu_x_l=6 15 | cpu_y_l=21 16 | cpu_width_l=108 17 | memory_x_l=114 18 | memory_y_l=21 19 | memory_width_l=110 20 | show_up_l = 1 21 | show_down_l = 1 22 | show_cpu_l = 1 23 | show_memory_l = 1 24 | 25 | width_s=153 26 | height_s=28 27 | cpu_x_s=6 28 | cpu_y_s=4 29 | cpu_width_s=70 30 | memory_x_s=77 31 | memory_y_s=4 32 | memory_width_s=77 33 | show_item_s = 12 34 | show_up_s = 0 35 | show_down_s = 0 36 | show_cpu_s = 1 37 | show_memory_s = 1 38 | -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/UpdateVisitor.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UpdateVisitor.h" 3 | 4 | namespace OpenHardwareMonitorApi 5 | { 6 | void UpdateVisitor::VisitComputer(IComputer ^ computer) 7 | { 8 | computer->Traverse(this); 9 | } 10 | 11 | void UpdateVisitor::VisitHardware(IHardware ^ hardware) 12 | { 13 | hardware->Update(); 14 | for each (IHardware^ subHardware in hardware->SubHardware) 15 | { 16 | subHardware->Accept(this); 17 | } 18 | } 19 | 20 | void UpdateVisitor::VisitSensor(ISensor ^ sensor) 21 | { 22 | } 23 | 24 | void UpdateVisitor::VisitParameter(IParameter ^ parameter) 25 | { 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /TrafficMonitor/TrafficMonitor.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TrafficMonitor.rc 5 | 6 | 7 | Mixed 8 | WindowsLocalDebugger 9 | 10 | 11 | Mixed 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /LICENSE_CN: -------------------------------------------------------------------------------- 1 | 版权所有(c)<2019> 2 | 3 | 反996许可证版本1.0 4 | 5 | 在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以 6 | 下统称为“授权作品”)的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括 7 | 但不限于使用、复制,修改,衍生利用、散布,发布和再许可: 8 | 9 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修 10 | 改。 11 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地( 12 | 以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖区 13 | 没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国际 14 | 劳工标准的核心公约。 15 | 3. 个人或法人不得以任何方式诱导、暗示或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意 16 | 直接或间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利 17 | 或补救措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该等个人或法人实体也不得以任 18 | 何方法限制其雇员或独立承包人向版权持有人或监督许可证合规情况的有关当局报告或投诉上述违反许可证 19 | 的行为的权利。 20 | 21 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵 22 | 权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或 23 | 本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。 24 | -------------------------------------------------------------------------------- /TrafficMonitor/DonateDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include "PictureStatic.h" 4 | #include "BaseDialog.h" 5 | 6 | // CDonateDlg 对话框 7 | 8 | class CDonateDlg : public CBaseDialog 9 | { 10 | DECLARE_DYNAMIC(CDonateDlg) 11 | 12 | public: 13 | CDonateDlg(CWnd* pParent = NULL); // 标准构造函数 14 | virtual ~CDonateDlg(); 15 | 16 | // 对话框数据 17 | #ifdef AFX_DESIGN_TIME 18 | enum { IDD = IDD_DONATE_DIALOG }; 19 | #endif 20 | 21 | protected: 22 | //CPictureStatic m_donate_pic; 23 | CRect m_pic1_rect; 24 | CRect m_pic2_rect; 25 | 26 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 27 | virtual CString GetDialogName() const override; 28 | 29 | DECLARE_MESSAGE_MAP() 30 | 31 | public: 32 | virtual BOOL OnInitDialog(); 33 | afx_msg void OnPaint(); 34 | }; 35 | -------------------------------------------------------------------------------- /PluginDemo/PluginSystemDate.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include "PluginSystemDate.h" 4 | #include "DataManager.h" 5 | 6 | CPluginSystemDate::CPluginSystemDate() 7 | { 8 | } 9 | 10 | const wchar_t* CPluginSystemDate::GetItemName() const 11 | { 12 | return CDataManager::Instance().StringRes(IDS_DATE); 13 | } 14 | 15 | const wchar_t* CPluginSystemDate::GetItemId() const 16 | { 17 | return L"o282ffc4"; 18 | } 19 | 20 | const wchar_t* CPluginSystemDate::GetItemLableText() const 21 | { 22 | return CDataManager::Instance().StringRes(IDS_DATE); 23 | } 24 | 25 | const wchar_t* CPluginSystemDate::GetItemValueText() const 26 | { 27 | return CDataManager::Instance().m_cur_date.c_str(); 28 | } 29 | 30 | const wchar_t* CPluginSystemDate::GetItemValueSampleText() const 31 | { 32 | return L"2022/08/08"; 33 | } 34 | -------------------------------------------------------------------------------- /PluginDemo/DataManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #define g_data CDataManager::Instance() 6 | 7 | struct SettingData 8 | { 9 | bool show_second{}; 10 | //bool show_label_text{}; 11 | }; 12 | 13 | class CDataManager 14 | { 15 | private: 16 | CDataManager(); 17 | ~CDataManager(); 18 | 19 | public: 20 | static CDataManager& Instance(); 21 | 22 | void LoadConfig(const std::wstring& config_dir); 23 | void SaveConfig() const; 24 | const CString& StringRes(UINT id); //根据资源id获取一个字符串资源 25 | 26 | public: 27 | std::wstring m_cur_time; 28 | std::wstring m_cur_date; 29 | SYSTEMTIME m_system_time; 30 | SettingData m_setting_data; 31 | 32 | private: 33 | static CDataManager m_instance; 34 | std::wstring m_config_path; 35 | std::map m_string_table; 36 | }; 37 | -------------------------------------------------------------------------------- /PluginDemo/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ 生成的包含文件。 3 | // 供 PluginDemo.rc 使用 4 | // 5 | #define IDD_DIALOG1 101 6 | #define IDD_OPTIONS_DIALOG 101 7 | #define IDS_PLUGIN_NAME 103 8 | #define IDS_PLUGIN_DESCRIPTION 104 9 | #define IDS_TIME 105 10 | #define IDS_DATE 106 11 | #define IDS_CUSTOM_DRAW_ITEM 107 12 | #define IDC_SHOW_SECOND_CHECK 1001 13 | #define IDC_SHOW_LABEL_CHECK 1002 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 104 20 | #define _APS_NEXT_COMMAND_VALUE 40001 21 | #define _APS_NEXT_CONTROL_VALUE 1003 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10(竖排)/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=9586944 3 | skin_author="zy" 4 | [layout] 5 | text_height=20 6 | no_text=1 7 | preview_width=238 8 | preview_height=79 9 | width_l=110 10 | height_l=63 11 | up_x_l=24 12 | up_y_l=2 13 | up_width_l=85 14 | down_x_l=24 15 | down_y_l=21 16 | down_width_l=85 17 | cpu_x_l=24 18 | cpu_y_l=40 19 | cpu_width_l=34 20 | memory_x_l=76 21 | memory_y_l=40 22 | memory_width_l=33 23 | show_up_l=1 24 | show_down_l=1 25 | show_cpu_l=1 26 | show_memory_l=1 27 | preview_x_l=115 28 | preview_y_l=0 29 | width_s=100 30 | height_s=43 31 | up_x_s=24 32 | up_y_s=2 33 | up_width_s=76 34 | down_x_s=24 35 | down_y_s=20 36 | down_width_s=76 37 | cpu_x_s=0 38 | cpu_y_s=0 39 | cpu_width_s=0 40 | memory_x_s=0 41 | memory_y_s=0 42 | memory_width_s=0 43 | show_up_s=1 44 | show_down_s=1 45 | show_cpu_s=0 46 | show_memory_s=0 47 | preview_x_s=0 48 | preview_y_s=0 49 | -------------------------------------------------------------------------------- /TrafficMonitor/TinyXml2Helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tinyxml2/tinyxml2.h" 3 | #include 4 | #include 5 | 6 | class CTinyXml2Helper 7 | { 8 | public: 9 | 10 | //从文件读取XML内容 11 | static bool LoadXmlFile(tinyxml2::XMLDocument& doc, const wchar_t* file_path); 12 | 13 | //遍历一个XML节点 14 | //fun: 一个函数对象,遍历到一个节点时被调用 15 | static void IterateChildNode(tinyxml2::XMLElement* ele, std::function fun); 16 | 17 | //获取一个节点的属性(返回值不会为空指针,如果找不到则返回空字符串) 18 | static const char* ElementAttribute(tinyxml2::XMLElement* ele, const char* attr); 19 | 20 | //获取一个节点的名称(返回值不会为空指针,如果找不到则返回空字符串) 21 | static const char* ElementName(tinyxml2::XMLElement* ele); 22 | 23 | //获取一个节点的文本(返回值不会为空指针,如果找不到则返回空字符串) 24 | static const char* ElementText(tinyxml2::XMLElement* ele); 25 | 26 | static bool StringToBool(const char* str); 27 | }; 28 | -------------------------------------------------------------------------------- /TrafficMonitor/WinVersionHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CWinVersionHelper 3 | { 4 | public: 5 | CWinVersionHelper(); 6 | ~CWinVersionHelper(); 7 | 8 | bool IsWindows11OrLater() const; //判断当前Windows版本是否为Win11或更新的版本 9 | bool IsWindows10FallCreatorOrLater() const; //判断当前Windows版本是否为Win10秋季创意者更新或更新的版本 10 | bool IsWindows7() const; //判断Windows版本是否为Windows7 11 | bool IsWindows8Or8point1() const; //判断Windows版本是否为Windows8或Windows8.1 12 | bool IsWindows8Point1OrLater() const; //判断Windows版本是否大于等于Windows8.1 13 | bool IsWindows8OrLater() const; 14 | bool IsWindows10OrLater() const; 15 | 16 | int GetMajorVersion() const { return m_major_version; } 17 | int GetMinorVersion() const { return m_minor_version; } 18 | int GetBuildNumber() const { return m_build_number; } 19 | protected: 20 | int m_major_version{}; 21 | int m_minor_version{}; 22 | int m_build_number{}; 23 | }; 24 | -------------------------------------------------------------------------------- /PluginDemo/PluginSystemTime.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include "PluginSystemTime.h" 4 | #include "DataManager.h" 5 | 6 | CPluginSystemTime::CPluginSystemTime() 7 | { 8 | } 9 | 10 | const wchar_t* CPluginSystemTime::GetItemName() const 11 | { 12 | return CDataManager::Instance().StringRes(IDS_TIME); 13 | } 14 | 15 | const wchar_t* CPluginSystemTime::GetItemId() const 16 | { 17 | return L"ra1YX2g1"; 18 | } 19 | 20 | const wchar_t* CPluginSystemTime::GetItemLableText() const 21 | { 22 | return CDataManager::Instance().StringRes(IDS_TIME); 23 | } 24 | 25 | const wchar_t* CPluginSystemTime::GetItemValueText() const 26 | { 27 | return CDataManager::Instance().m_cur_time.c_str(); 28 | } 29 | 30 | const wchar_t* CPluginSystemTime::GetItemValueSampleText() const 31 | { 32 | if (CDataManager::Instance().m_setting_data.show_second) 33 | return L"12:00:00"; 34 | else 35 | return L"12:00"; 36 | } 37 | -------------------------------------------------------------------------------- /TrafficMonitor/AppAlreadyRuningDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CAppAlreadyRuningDlg 对话框 5 | 6 | class CAppAlreadyRuningDlg : public CDialog 7 | { 8 | DECLARE_DYNAMIC(CAppAlreadyRuningDlg) 9 | 10 | public: 11 | CAppAlreadyRuningDlg(HWND handel, CWnd* pParent = nullptr); // 标准构造函数 12 | virtual ~CAppAlreadyRuningDlg(); 13 | 14 | // 对话框数据 15 | #ifdef AFX_DESIGN_TIME 16 | enum { IDD = IDD_APP_ALREAD_RUNING_DIALOG }; 17 | #endif 18 | 19 | private: 20 | HWND m_handle{}; //正在运行的TrafficMonitor进程主窗口的句柄 21 | 22 | protected: 23 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 24 | 25 | DECLARE_MESSAGE_MAP() 26 | public: 27 | virtual BOOL OnInitDialog(); 28 | afx_msg void OnBnClickedExitInstButton(); 29 | afx_msg void OnBnClickedOpenSettingsButton(); 30 | afx_msg void OnBnClickedShowHideMainWindowButton(); 31 | afx_msg void OnBnClickedShowHideTaskbarWindowButton(); 32 | }; 33 | -------------------------------------------------------------------------------- /TrafficMonitor/FilePathHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CFilePathHelper 3 | { 4 | public: 5 | CFilePathHelper(const wstring& file_path); 6 | CFilePathHelper(){} 7 | ~CFilePathHelper(); 8 | 9 | void SetFilePath(const wstring& file_path) { m_file_path = file_path; } 10 | 11 | wstring GetFileExtension(bool upper = false, bool width_dot = false) const; //获取文件的扩展名(upper:是否大写; width_dot:是否包含“.”) 12 | wstring GetFileName() const; //获取文件名 13 | wstring GetFileNameWithoutExtension() const; //获取文件名(不含扩展名) 14 | wstring GetFolderName() const; //获取文件夹名 15 | wstring GetDir() const; //获取目录 16 | wstring GetParentDir() const; //获取上级目录 17 | wstring GetFilePath() const { return m_file_path; } //获取完整路径 18 | const wstring& ReplaceFileExtension(const wchar_t* new_extension); //替换文件的扩展名,返回文件完整路径 19 | wstring GetFilePathWithoutExtension() const; //获取文件路径(不含扩展名) 20 | protected: 21 | wstring m_file_path; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /TrafficMonitor/CSkinPreviewView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DrawCommon.h" 3 | #include "SkinFile.h" 4 | 5 | 6 | // CSkinPreviewView 视图 7 | 8 | 9 | class CSkinPreviewView : public CScrollView 10 | { 11 | DECLARE_DYNCREATE(CSkinPreviewView) 12 | 13 | protected: 14 | CSkinPreviewView(); // 动态创建所使用的受保护的构造函数 15 | virtual ~CSkinPreviewView(); 16 | 17 | public: 18 | //#ifdef _DEBUG 19 | // virtual void AssertValid() const; 20 | //#ifndef _WIN32_WCE 21 | // virtual void Dump(CDumpContext& dc) const; 22 | //#endif 23 | //#endif 24 | 25 | //成员函数 26 | public: 27 | void InitialUpdate(); 28 | void SetSize(int width, int hight); 29 | void SetSkinData(CSkinFile* skin_data) { m_skin_data = skin_data; } 30 | 31 | //成员变量 32 | protected: 33 | CSize m_size; 34 | CPoint m_start_point; //绘图的起始位置 35 | 36 | CSkinFile* m_skin_data; 37 | 38 | protected: 39 | virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 40 | virtual void OnInitialUpdate(); // 构造后的第一次 41 | 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | 46 | -------------------------------------------------------------------------------- /TrafficMonitor/SelectConnectionsDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CommonData.h" 3 | #include "BaseDialog.h" 4 | 5 | // CSelectConnectionsDlg 对话框 6 | 7 | class CSelectConnectionsDlg : public CBaseDialog 8 | { 9 | DECLARE_DYNAMIC(CSelectConnectionsDlg) 10 | 11 | public: 12 | CSelectConnectionsDlg(const StringSet& connections_hide, CWnd* pParent = nullptr); // 标准构造函数 13 | virtual ~CSelectConnectionsDlg(); 14 | 15 | const StringSet& GetData() const { return m_connections_hide; } 16 | 17 | // 对话框数据 18 | #ifdef AFX_DESIGN_TIME 19 | enum { IDD = IDD_SELECT_CONNECTIONS_DIALOG }; 20 | #endif 21 | 22 | private: 23 | CCheckListBox m_list_ctrl; 24 | std::vector m_all_connection_names; 25 | StringSet m_connections_hide; 26 | 27 | protected: 28 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 29 | virtual CString GetDialogName() const override; 30 | 31 | DECLARE_MESSAGE_MAP() 32 | 33 | public: 34 | virtual BOOL OnInitDialog(); 35 | virtual void OnOK(); 36 | }; 37 | -------------------------------------------------------------------------------- /TrafficMonitor/ComboBox2.cpp: -------------------------------------------------------------------------------- 1 | // ComboBox2.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ComboBox2.h" 6 | 7 | 8 | // CComboBox2 9 | 10 | IMPLEMENT_DYNAMIC(CComboBox2, CComboBox) 11 | 12 | CComboBox2::CComboBox2() 13 | { 14 | 15 | } 16 | 17 | CComboBox2::~CComboBox2() 18 | { 19 | } 20 | 21 | 22 | void CComboBox2::SetMouseWheelEnable(bool enable) 23 | { 24 | m_mouse_wheel_enable = enable; 25 | } 26 | 27 | BEGIN_MESSAGE_MAP(CComboBox2, CComboBox) 28 | END_MESSAGE_MAP() 29 | 30 | 31 | 32 | // CComboBox2 消息处理程序 33 | 34 | 35 | 36 | 37 | BOOL CComboBox2::PreTranslateMessage(MSG* pMsg) 38 | { 39 | // TODO: 在此添加专用代码和/或调用基类 40 | //如果m_mouse_wheel_enable为false,则不响应鼠标滚轮消息 41 | if (pMsg->message == WM_MOUSEWHEEL && !m_mouse_wheel_enable) 42 | { 43 | //将鼠标滚轮消息发送给父窗口 44 | CWnd* pParent = GetParent(); 45 | pParent->SendMessage(WM_MOUSEWHEEL, pMsg->wParam, pMsg->lParam); 46 | return true; 47 | } 48 | 49 | return CComboBox::PreTranslateMessage(pMsg); 50 | } 51 | -------------------------------------------------------------------------------- /TrafficMonitor/CAutoAdaptSettingsDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CAutoAdaptSettingsDlg 对话框 5 | 6 | class CAutoAdaptSettingsDlg : public CDialog 7 | { 8 | DECLARE_DYNAMIC(CAutoAdaptSettingsDlg) 9 | 10 | public: 11 | CAutoAdaptSettingsDlg(TaskBarSettingData& data, CWnd* pParent = nullptr); // 标准构造函数 12 | virtual ~CAutoAdaptSettingsDlg(); 13 | 14 | // 对话框数据 15 | #ifdef AFX_DESIGN_TIME 16 | enum { IDD = IDD_ATUO_ADAPT_SETTING_DIALOG }; 17 | #endif 18 | 19 | private: 20 | CComboBox m_dark_mode_default_style_combo; 21 | CComboBox m_light_mode_default_style_combo; 22 | TaskBarSettingData& m_data; 23 | CToolTipCtrl m_toolTip; 24 | 25 | private: 26 | void InitComboBox(CComboBox& combo_box, int style_sel); 27 | int GetComboBoxSel(const CComboBox& combo_box); 28 | 29 | protected: 30 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 31 | 32 | DECLARE_MESSAGE_MAP() 33 | public: 34 | virtual BOOL OnInitDialog(); 35 | virtual void OnOK(); 36 | virtual BOOL PreTranslateMessage(MSG* pMsg); 37 | }; 38 | -------------------------------------------------------------------------------- /TrafficMonitor/DCompositionSupport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "HResultException.h" 5 | #include "RenderAPISupport.h" 6 | 7 | class CDCompositionException final : public CHResultException 8 | { 9 | using CHResultException::CHResultException; 10 | }; 11 | 12 | class CDCompositionDevice 13 | { 14 | public: 15 | using Resource = CDeviceResource; 16 | using Type = Microsoft::WRL::ComPtr; 17 | using Storage = storage_t>; 18 | 19 | private: 20 | Type m_p_device{}; 21 | CResourceTracker m_resource_tracker{std::make_shared()}; 22 | 23 | public: 24 | void Recreate(Microsoft::WRL::ComPtr p_dxgi_device); 25 | auto GetStorage() 26 | -> std::shared_ptr; 27 | auto Get() 28 | -> Microsoft::WRL::ComPtr; 29 | }; 30 | 31 | class CDCompositionSupport 32 | { 33 | public: 34 | static bool CheckSupport(); 35 | }; 36 | -------------------------------------------------------------------------------- /PluginDemo/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 4 | //// Windows 头文件 5 | //#include 6 | 7 | #include 8 | 9 | #include // MFC 核心组件和标准组件 10 | #include // MFC 扩展 11 | #include // MFC 自动化类 12 | 13 | #ifdef _UNICODE 14 | #if defined _M_IX86 15 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 16 | #elif defined _M_X64 17 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 18 | #else 19 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤10/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=9586944 3 | skin_author="zy" 4 | [layout] 5 | text_height=20 6 | no_text=1 7 | preview_width=238 8 | preview_height=110 9 | width_l=189 10 | height_l=43 11 | up_x_l=24 12 | up_y_l=2 13 | up_width_l=73 14 | up_align_l=0 15 | down_x_l=116 16 | down_y_l=2 17 | down_width_l=73 18 | down_align_l=0 19 | cpu_x_l=24 20 | cpu_y_l=21 21 | cpu_width_l=73 22 | cpu_align_l=0 23 | memory_x_l=116 24 | memory_y_l=21 25 | memory_width_l=73 26 | memory_align_l=0 27 | show_up_l=1 28 | show_down_l=1 29 | show_cpu_l=1 30 | show_memory_l=1 31 | preview_x_l=0 32 | preview_y_l=47 33 | width_s=189 34 | height_s=28 35 | up_x_s=24 36 | up_y_s=4 37 | up_width_s=73 38 | up_align_s=0 39 | down_x_s=116 40 | down_y_s=4 41 | down_width_s=73 42 | down_align_s=0 43 | cpu_x_s=0 44 | cpu_y_s=0 45 | cpu_width_s=0 46 | cpu_align_s=0 47 | memory_x_s=0 48 | memory_y_s=0 49 | memory_width_s=0 50 | memory_align_s=0 51 | show_up_s=1 52 | show_down_s=1 53 | show_cpu_s=0 54 | show_memory_s=0 55 | preview_x_s=0 56 | preview_y_s=0 57 | -------------------------------------------------------------------------------- /PluginDemo/PluginDemo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | #include "PluginSystemDate.h" 4 | #include "PluginSystemTime.h" 5 | #include "CustomDrawItem.h" 6 | 7 | class CPluginDemo : public ITMPlugin 8 | { 9 | private: 10 | CPluginDemo(); 11 | 12 | public: 13 | static CPluginDemo& Instance(); 14 | 15 | // 通过 ITMPlugin 继承 16 | virtual IPluginItem* GetItem(int index) override; 17 | virtual void DataRequired() override; 18 | virtual const wchar_t* GetInfo(PluginInfoIndex index) override; 19 | virtual OptionReturn ShowOptionsDialog(void* hParent) override; 20 | virtual void OnExtenedInfo(ExtendedInfoIndex index, const wchar_t* data) override; 21 | 22 | private: 23 | CPluginSystemDate m_system_date; 24 | CPluginSystemTime m_system_time; 25 | CCustomDrawItem m_custom_draw_item; 26 | 27 | static CPluginDemo m_instance; 28 | }; 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | __declspec(dllexport) ITMPlugin* TMPluginGetInstance(); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /TrafficMonitor/TaskbarDefaultStyle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CommonData.h" 3 | 4 | #define TASKBAR_DEFAULT_STYLE_NUM 4 5 | #define TASKBAR_DEFAULT_LIGHT_STYLE_INDEX 3 6 | 7 | class CTaskbarDefaultStyle 8 | { 9 | public: 10 | struct TaskBarStyleData 11 | { 12 | std::map text_colors{}; 13 | COLORREF back_color{}; 14 | COLORREF transparent_color{}; 15 | COLORREF status_bar_color{}; 16 | bool specify_each_item_color{}; 17 | }; 18 | 19 | CTaskbarDefaultStyle(); 20 | ~CTaskbarDefaultStyle(); 21 | 22 | void LoadConfig(); 23 | void SaveConfig() const; 24 | 25 | void ApplyDefaultStyle(int index, TaskBarSettingData& data) const; //应用一个颜色预设 26 | //static void ApplyDefaultLightStyle(TaskBarSettingData& data); //应用默认的浅色模式预设 27 | void ModifyDefaultStyle(int index, TaskBarSettingData& data); //将当前颜色设置保存到一个预设方案 28 | 29 | static bool IsTaskBarStyleDataValid(const TaskBarStyleData& data); //判断一个颜色模式是否有效 30 | 31 | private: 32 | TaskBarStyleData m_default_style[TASKBAR_DEFAULT_STYLE_NUM]; //预设样式 33 | 34 | }; 35 | -------------------------------------------------------------------------------- /TrafficMonitor/MainWndColorDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ColorStatic.h" 3 | #include "afxwin.h" 4 | #include "ColorSettingListCtrl.h" 5 | #include "BaseDialog.h" 6 | 7 | // CMainWndColorDlg 对话框 8 | 9 | class CMainWndColorDlg : public CBaseDialog 10 | { 11 | DECLARE_DYNAMIC(CMainWndColorDlg) 12 | 13 | public: 14 | CMainWndColorDlg(const std::map& colors, CWnd* pParent = NULL); // 标准构造函数 15 | virtual ~CMainWndColorDlg(); 16 | 17 | const std::map& GetColors() const { return m_colors; } 18 | 19 | // 对话框数据 20 | #ifdef AFX_DESIGN_TIME 21 | enum { IDD = IDD_MAIN_COLOR_DIALOG }; 22 | #endif 23 | protected: 24 | std::map m_colors; 25 | CColorSettingListCtrl m_list_ctrl; 26 | 27 | virtual CString GetDialogName() const override; 28 | 29 | protected: 30 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 31 | 32 | DECLARE_MESSAGE_MAP() 33 | public: 34 | virtual BOOL OnInitDialog(); 35 | afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult); 36 | }; 37 | -------------------------------------------------------------------------------- /TrafficMonitor/UpdateHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CUpdateHelper 3 | { 4 | public: 5 | CUpdateHelper(); 6 | ~CUpdateHelper(); 7 | 8 | enum class UpdateSource 9 | { 10 | GitHubSource, 11 | GiteeSource 12 | }; 13 | 14 | void SetUpdateSource(UpdateSource update_source); 15 | 16 | bool CheckForUpdate(); 17 | 18 | const std::wstring& GetVersion() const; 19 | const std::wstring& GetLink() const; 20 | const std::wstring& GetLink64() const; 21 | const std::wstring& GetContentsEn() const; 22 | const std::wstring& GetContentsZhCn() const; 23 | const std::wstring& GetContentsZhTw() const; 24 | bool IsRowData(); 25 | 26 | private: 27 | void ParseUpdateInfo(wstring version_info); 28 | 29 | private: 30 | std::wstring m_version; 31 | std::wstring m_link; 32 | std::wstring m_link64; 33 | std::wstring m_contents_en; 34 | std::wstring m_contents_zh_cn; 35 | std::wstring m_contents_zh_tw; 36 | bool m_row_data{ true }; 37 | UpdateSource m_update_source{ UpdateSource::GitHubSource }; 38 | }; 39 | -------------------------------------------------------------------------------- /TrafficMonitor/DCompositionSupport.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DCompositionSupport.h" 3 | #include "Common.h" 4 | #include "DllFunctions.h" 5 | 6 | void CDCompositionDevice::Recreate(Microsoft::WRL::ComPtr p_dxgi_device) 7 | { 8 | ThrowIfFailed( 9 | CDllFunctions::DCompositionCreateDevice( 10 | p_dxgi_device.Get(), 11 | IID_PPV_ARGS(&m_p_device)), 12 | TRAFFICMONITOR_ERROR_STR("Recreate DComposition device failed.")); 13 | 14 | NotifyAllResourceWhenDeviceRecreate(m_resource_tracker, m_p_device); 15 | } 16 | 17 | auto CDCompositionDevice::GetStorage() 18 | -> std::shared_ptr 19 | { 20 | return m_resource_tracker.GetSharedResourceTrackerStorage(); 21 | } 22 | 23 | bool CDCompositionSupport::CheckSupport() 24 | { 25 | static auto result = 26 | FunctionChecker::CheckFunctionExist(_T("dcomp.dll"), "DCompositionCreateDevice"); 27 | return result; 28 | } 29 | 30 | auto CDCompositionDevice::Get() 31 | -> Microsoft::WRL::ComPtr 32 | { 33 | return m_p_device; 34 | } 35 | -------------------------------------------------------------------------------- /TrafficMonitor/TaskbarColorDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ColorStatic.h" 3 | #include "afxwin.h" 4 | #include "ColorSettingListCtrl.h" 5 | #include "BaseDialog.h" 6 | 7 | // CTaskbarColorDlg 对话框 8 | 9 | class CTaskbarColorDlg : public CBaseDialog 10 | { 11 | DECLARE_DYNAMIC(CTaskbarColorDlg) 12 | 13 | public: 14 | CTaskbarColorDlg(const std::map& colors, CWnd* pParent = NULL); // 标准构造函数 15 | virtual ~CTaskbarColorDlg(); 16 | 17 | const std::map& GetColors() const { return m_colors; } 18 | 19 | // 对话框数据 20 | #ifdef AFX_DESIGN_TIME 21 | enum { IDD = IDD_TASKBAR_COLOR_DIALOG }; 22 | #endif 23 | 24 | protected: 25 | std::map m_colors; 26 | CColorSettingListCtrl m_list_ctrl; 27 | 28 | virtual CString GetDialogName() const override; 29 | 30 | protected: 31 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 32 | 33 | DECLARE_MESSAGE_MAP() 34 | public: 35 | virtual BOOL OnInitDialog(); 36 | afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult); 37 | }; 38 | -------------------------------------------------------------------------------- /TrafficMonitor/DisplayTextSettingDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BaseDialog.h" 3 | #include "CommonData.h" 4 | #include "ListCtrlEx.h" 5 | 6 | // CDisplayTextSettingDlg 对话框 7 | 8 | class CDisplayTextSettingDlg : public CBaseDialog 9 | { 10 | DECLARE_DYNAMIC(CDisplayTextSettingDlg) 11 | 12 | public: 13 | CDisplayTextSettingDlg(DispStrings& display_texts, bool main_window_text = false, CWnd* pParent = nullptr); // 标准构造函数 14 | virtual ~CDisplayTextSettingDlg(); 15 | 16 | // 对话框数据 17 | #ifdef AFX_DESIGN_TIME 18 | enum { IDD = IDD_DISPLAY_TEXT_SETTINGS_DIALOG }; 19 | #endif 20 | 21 | private: 22 | DispStrings& m_display_texts; 23 | 24 | CListCtrlEx m_list_ctrl; 25 | bool m_main_window_text{ false }; //如果为true,则为主窗口文本设置,否则为任务栏窗口设置 26 | 27 | protected: 28 | virtual CString GetDialogName() const override; 29 | CommonDisplayItem GetDisplayItem(int row); 30 | 31 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 32 | 33 | DECLARE_MESSAGE_MAP() 34 | 35 | public: 36 | virtual BOOL OnInitDialog(); 37 | virtual void OnOK(); 38 | afx_msg void OnBnClickedRestoreDefaultButton(); 39 | }; 40 | -------------------------------------------------------------------------------- /TrafficMonitor/skins/皮肤11/skin.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | text_color=16777215,0,0,0, 3 | specify_each_item_color=0 4 | skin_author="zy" 5 | font_name="Segoe UI Semibold" 6 | font_size=10 7 | font_style=0 8 | [layout] 9 | text_height=20 10 | no_text=1 11 | preview_width=171 12 | preview_height=108 13 | width_l=174 14 | height_l=41 15 | up_x_l=16 16 | up_y_l=1 17 | up_width_l=69 18 | up_align_l=1 19 | down_x_l=16 20 | down_y_l=20 21 | down_width_l=69 22 | down_align_l=1 23 | cpu_x_l=90 24 | cpu_y_l=20 25 | cpu_width_l=42 26 | cpu_align_l=2 27 | memory_x_l=132 28 | memory_y_l=20 29 | memory_width_l=42 30 | memory_align_l=2 31 | show_up_l=1 32 | show_down_l=1 33 | show_cpu_l=1 34 | show_memory_l=1 35 | preview_x_l=0 36 | preview_y_l=55 37 | width_s=90 38 | height_s=41 39 | up_x_s=16 40 | up_y_s=1 41 | up_width_s=69 42 | up_align_s=1 43 | down_x_s=16 44 | down_y_s=20 45 | down_width_s=69 46 | down_align_s=1 47 | cpu_x_s=0 48 | cpu_y_s=0 49 | cpu_width_s=0 50 | cpu_align_s=0 51 | memory_x_s=0 52 | memory_y_s=0 53 | memory_width_s=0 54 | memory_align_s=0 55 | show_up_s=1 56 | show_down_s=1 57 | show_cpu_s=0 58 | show_memory_s=0 59 | preview_x_s=0 60 | preview_y_s=0 61 | -------------------------------------------------------------------------------- /TrafficMonitor/ColorStatic.h: -------------------------------------------------------------------------------- 1 | // CColorStatic 2 | //派生自CStatic,用于显示颜色的Static控件 3 | #pragma once 4 | #define WM_STATIC_CLICKED (WM_USER + 1001) 5 | 6 | class CColorStatic : public CStatic 7 | { 8 | DECLARE_DYNAMIC(CColorStatic) 9 | 10 | public: 11 | CColorStatic(); 12 | virtual ~CColorStatic(); 13 | 14 | void SetFillColor(COLORREF fill_color); //设置要填充单一的背景色 15 | void SetColorNum(int color_num); //设置颜色的数量 16 | void SetFillColor(int index, COLORREF fill_color); 17 | void SetLinkCursor(bool link_cursor = true); //设置指向控件时光标变成超链接形状 18 | void EnableWindow(bool enable); 19 | 20 | protected: 21 | //COLORREF m_fill_color{ RGB(255, 255,255) }; 22 | vector m_colors; 23 | bool m_hover{ false }; //当鼠标指向控件时为true 24 | bool m_link_cursor{ false }; //是否启用超链接形状的光标 25 | 26 | protected: 27 | DECLARE_MESSAGE_MAP() 28 | public: 29 | afx_msg void OnPaint(); 30 | afx_msg void OnMouseHover(UINT nFlags, CPoint point); 31 | afx_msg void OnMouseLeave(); 32 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); 33 | virtual void PreSubclassWindow(); 34 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); 35 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); 36 | }; 37 | -------------------------------------------------------------------------------- /TrafficMonitor/SupportedRenderEnums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "IDrawCommon.h" 4 | 5 | class CSupportedRenderEnums 6 | { 7 | private: 8 | std::bitset<3> m_enums{1}; 9 | 10 | public: 11 | constexpr static std::size_t DEFAULT_INDEX = 0; 12 | constexpr static std::size_t D2D1_WITH_DCOMPOSITION_INDEX = 1; 13 | constexpr static std::size_t D2D1_INDEX = 2; 14 | 15 | CSupportedRenderEnums(); 16 | ~CSupportedRenderEnums() = default; 17 | void EnableDefaultOnly() noexcept; 18 | void DisableD2D1() noexcept; 19 | /** 20 | * @brief 根据D2D1 > D2D1_WITH_DCOMPOSITION > DEFAULT的顺序返回枚举 21 | * 22 | * @return DrawCommonHelper::RenderType 23 | */ 24 | auto GetAutoFitEnum() const noexcept 25 | -> DrawCommonHelper::RenderType; 26 | /** 27 | * @brief (已弃用) 28 | 根据D2D1_WITH_DCOMPOSITION > D2D1 > DEFAULT的顺序返回枚举 29 | * 30 | * @return DrawCommonHelper::RenderType 31 | */ 32 | [[deprecated("May no longer be needed.")]] 33 | auto GetMaxSupportedRenderEnum() const noexcept 34 | -> DrawCommonHelper::RenderType; 35 | bool IsD2D1WithDCompositionEnabled() const noexcept; 36 | bool IsD2D1Enabled() const noexcept; 37 | }; 38 | -------------------------------------------------------------------------------- /TrafficMonitor/TabDlg.h: -------------------------------------------------------------------------------- 1 | //这是用于Tab标签中的子对话框类 2 | #pragma once 3 | class CTabDlg : public CDialogEx 4 | { 5 | DECLARE_DYNAMIC(CTabDlg) 6 | public: 7 | CTabDlg(UINT nIDTemplate, CWnd *pParent = NULL); 8 | ~CTabDlg(); 9 | virtual BOOL PreTranslateMessage(MSG* pMsg); 10 | virtual BOOL OnInitDialog(); 11 | CWnd* GetParentWindow(); 12 | void SetScrollbarInfo(int nPage, int nMax); 13 | void ResetScroll(); 14 | virtual void OnTabEntered() {} //当标签切换到当前窗口时被调用 15 | virtual void OnOK(); 16 | void SetScrollEnable(bool enable) { m_scroll_enable = enable; } 17 | virtual void SetControlMouseWheelEnable(bool enable) {} //在派生类中重写此函数以设置控件是否允许响应鼠标滚轮 18 | 19 | bool IsScrollBarVisible(); //滚动条是否可见 20 | 21 | protected: 22 | void ScrollWindowSimple(int step); 23 | 24 | void EnableDlgCtrl(UINT id, bool enable); 25 | void ShowDlgCtrl(UINT id, bool show); 26 | 27 | protected: 28 | CWnd* m_pParent; 29 | bool m_scroll_enable{ false }; 30 | int m_last_pos{}; 31 | 32 | public: 33 | DECLARE_MESSAGE_MAP() 34 | afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 35 | afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); 36 | afx_msg void OnSize(UINT nType, int cx, int cy); 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxcmn.h" 3 | #include "Common.h" 4 | #include "HistoryTrafficListDlg.h" 5 | #include "HistoryTrafficCalendarDlg.h" 6 | #include "BaseDialog.h" 7 | 8 | // CHistoryTrafficDlg 对话框 9 | 10 | class CHistoryTrafficDlg : public CBaseDialog 11 | { 12 | DECLARE_DYNAMIC(CHistoryTrafficDlg) 13 | 14 | public: 15 | CHistoryTrafficDlg(deque& history_traffics, CWnd* pParent = NULL); // 标准构造函数 16 | virtual ~CHistoryTrafficDlg(); 17 | 18 | // 对话框数据 19 | #ifdef AFX_DESIGN_TIME 20 | enum { IDD = IDD_HISTORY_TRAFFIC_DIALOG }; 21 | #endif 22 | 23 | public: 24 | CHistoryTrafficListDlg m_tab1_dlg; 25 | CHistoryTrafficCalendarDlg m_tab2_dlg; 26 | 27 | protected: 28 | deque& m_history_traffics; 29 | 30 | CTabCtrl m_tab; 31 | int m_tab_selected; 32 | 33 | protected: 34 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 35 | void SetTabWndSize(); 36 | virtual CString GetDialogName() const override; 37 | 38 | DECLARE_MESSAGE_MAP() 39 | public: 40 | virtual BOOL OnInitDialog(); 41 | virtual BOOL PreTranslateMessage(MSG* pMsg); 42 | afx_msg void OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult); 43 | afx_msg void OnSize(UINT nType, int cx, int cy); 44 | }; 45 | -------------------------------------------------------------------------------- /TrafficMonitor/OptionsDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MainWndSettingsDlg.h" 3 | #include "TaskBarSettingsDlg.h" 4 | #include "GeneralSettingsDlg.h" 5 | #include "afxcmn.h" 6 | #include "CTabCtrlEx.h" 7 | #include "BaseDialog.h" 8 | 9 | // COptionsDlg 对话框 10 | 11 | #define OPTION_DLG_NAME _T("OptionsDlg") 12 | 13 | class COptionsDlg : public CBaseDialog 14 | { 15 | DECLARE_DYNAMIC(COptionsDlg) 16 | 17 | public: 18 | COptionsDlg(int tab = 0, CWnd* pParent = NULL); // 标准构造函数 19 | virtual ~COptionsDlg(); 20 | 21 | // 对话框数据 22 | #ifdef AFX_DESIGN_TIME 23 | enum { IDD = IDD_OPTIONS_DIALOG }; 24 | #endif 25 | 26 | CMainWndSettingsDlg m_tab1_dlg{ this }; 27 | CTaskBarSettingsDlg m_tab2_dlg{ this }; 28 | CGeneralSettingsDlg m_tab3_dlg{ this }; 29 | 30 | protected: 31 | CTabCtrlEx m_tab; 32 | int m_tab_selected; 33 | std::vector m_tab_vect; 34 | std::vector m_tab_height; 35 | 36 | virtual CString GetDialogName() const override; 37 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 38 | 39 | DECLARE_MESSAGE_MAP() 40 | public: 41 | virtual BOOL OnInitDialog(); 42 | virtual void OnOK(); 43 | afx_msg void OnSize(UINT nType, int cx, int cy); 44 | virtual void OnCancel(); 45 | afx_msg void OnBnClickedApplyButton(); 46 | }; 47 | -------------------------------------------------------------------------------- /PluginDemo/OptionsDlg.cpp: -------------------------------------------------------------------------------- 1 | // OptionsDlg.cpp: 实现文件 2 | // 3 | 4 | #include "pch.h" 5 | #include "PluginDemo.h" 6 | #include "OptionsDlg.h" 7 | #include "afxdialogex.h" 8 | 9 | 10 | // COptionsDlg 对话框 11 | 12 | IMPLEMENT_DYNAMIC(COptionsDlg, CDialog) 13 | 14 | COptionsDlg::COptionsDlg(CWnd* pParent /*=nullptr*/) 15 | : CDialog(IDD_OPTIONS_DIALOG, pParent) 16 | { 17 | 18 | } 19 | 20 | COptionsDlg::~COptionsDlg() 21 | { 22 | } 23 | 24 | void COptionsDlg::DoDataExchange(CDataExchange* pDX) 25 | { 26 | CDialog::DoDataExchange(pDX); 27 | } 28 | 29 | 30 | BEGIN_MESSAGE_MAP(COptionsDlg, CDialog) 31 | ON_BN_CLICKED(IDC_SHOW_SECOND_CHECK, &COptionsDlg::OnBnClickedShowSecondCheck) 32 | END_MESSAGE_MAP() 33 | 34 | 35 | // COptionsDlg 消息处理程序 36 | 37 | 38 | BOOL COptionsDlg::OnInitDialog() 39 | { 40 | CDialog::OnInitDialog(); 41 | 42 | // TODO: 在此添加额外的初始化 43 | //初始化控件状态 44 | CheckDlgButton(IDC_SHOW_SECOND_CHECK, m_data.show_second); 45 | //CheckDlgButton(IDC_SHOW_LABEL_CHECK, m_data.show_label_text); 46 | 47 | return TRUE; // return TRUE unless you set the focus to a control 48 | // 异常: OCX 属性页应返回 FALSE 49 | } 50 | 51 | 52 | void COptionsDlg::OnBnClickedShowSecondCheck() 53 | { 54 | // TODO: 在此添加控件通知处理程序代码 55 | m_data.show_second = (IsDlgButtonChecked(IDC_SHOW_SECOND_CHECK) != 0); 56 | } 57 | -------------------------------------------------------------------------------- /TrafficMonitor/CMFCColorDialogEx.cpp: -------------------------------------------------------------------------------- 1 | // CMFCColorDialogEx.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "CMFCColorDialogEx.h" 6 | #include "Common.h" 7 | 8 | // CMFCColorDialogEx 9 | 10 | //IMPLEMENT_DYNAMIC(CMFCColorDialogEx, CMFCColorDialog) 11 | 12 | CMFCColorDialogEx::CMFCColorDialogEx(COLORREF clrInit, DWORD dwFlags, CWnd* pParentWnd, HPALETTE hPal) 13 | :CMFCColorDialog(clrInit, dwFlags, pParentWnd, hPal) 14 | { 15 | 16 | } 17 | 18 | CMFCColorDialogEx::~CMFCColorDialogEx() 19 | { 20 | } 21 | 22 | 23 | BEGIN_MESSAGE_MAP(CMFCColorDialogEx, CMFCColorDialog) 24 | END_MESSAGE_MAP() 25 | 26 | 27 | 28 | // CMFCColorDialogEx 消息处理程序 29 | 30 | BOOL CMFCColorDialogEx::OnInitDialog() 31 | { 32 | CMFCColorDialog::OnInitDialog(); 33 | 34 | // TODO: 在此添加额外的初始化 35 | 36 | //设置控件字体 37 | CWnd* pParent = GetParent(); 38 | if (pParent != nullptr) 39 | { 40 | CCommon::SetDialogFont(this, pParent->GetFont()); 41 | 42 | CWnd* pPropSheet = m_pColourSheetOne->GetParent(); 43 | if (pPropSheet != nullptr) 44 | CCommon::SetDialogFont(pPropSheet, pParent->GetFont()); 45 | 46 | //CCommon::SetDialogFont(m_pColourSheetOne, pParent->GetFont()); 47 | //CCommon::SetDialogFont(m_pColourSheetTwo, pParent->GetFont()); 48 | } 49 | 50 | 51 | return TRUE; // return TRUE unless you set the focus to a control 52 | // 异常: OCX 属性页应返回 FALSE 53 | } 54 | 55 | -------------------------------------------------------------------------------- /TrafficMonitor/CVariant.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CVariant.h" 3 | 4 | 5 | CVariant::CVariant(int value) 6 | { 7 | m_value_int = value; 8 | m_type = eType::INT; 9 | } 10 | 11 | CVariant::CVariant(size_t value) 12 | { 13 | m_value_int = static_cast(value); 14 | m_type = eType::UINT; 15 | } 16 | 17 | CVariant::CVariant(double value) 18 | { 19 | m_value_double = value; 20 | m_type = eType::DOUBLE; 21 | } 22 | 23 | CVariant::CVariant(LPCTSTR value) 24 | { 25 | m_value_string = value; 26 | m_type = eType::STRING; 27 | } 28 | 29 | CVariant::CVariant(const CString& value) 30 | { 31 | m_value_string = value; 32 | m_type = eType::STRING; 33 | } 34 | 35 | CVariant::CVariant(const wstring & value) 36 | { 37 | m_value_string = value.c_str(); 38 | m_type = eType::STRING; 39 | } 40 | 41 | CVariant::~CVariant() 42 | { 43 | } 44 | 45 | CString CVariant::ToString() const 46 | { 47 | CString str; 48 | switch (m_type) 49 | { 50 | case CVariant::eType::INT: 51 | str.Format(_T("%d"), m_value_int); 52 | break; 53 | case eType::UINT: 54 | str.Format(_T("%u"), static_cast(m_value_int)); 55 | break; 56 | case CVariant::eType::DOUBLE: 57 | str.Format(_T("%g"), m_value_double); 58 | break; 59 | case CVariant::eType::STRING: 60 | str = m_value_string; 61 | break; 62 | default: 63 | break; 64 | } 65 | return str; 66 | } 67 | -------------------------------------------------------------------------------- /TrafficMonitor/BaseDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // CBaseDialog 对话框 5 | //用于实现记住对话框大小 6 | //并将窗口初始大小设置为最小大小 7 | 8 | class CBaseDialog : public CDialog 9 | { 10 | DECLARE_DYNAMIC(CBaseDialog) 11 | 12 | public: 13 | CBaseDialog(UINT nIDTemplate, CWnd* pParent = NULL); // 标准构造函数 14 | virtual ~CBaseDialog(); 15 | 16 | // 对话框数据 17 | //#ifdef AFX_DESIGN_TIME 18 | // enum { IDD = IDD_BASEDIALOG }; 19 | //#endif 20 | 21 | void SetMinSize(int cx, int cy); //设置窗口的最小大小,如果未设置,则使用窗口的初始大小作为最小大小 22 | static HWND GetUniqueHandel(LPCTSTR dlg_name); //获指定窗口唯一的句柄 23 | static const std::map& AllUniqueHandels(); //获取所有窗口的句柄 24 | 25 | private: 26 | void LoadConfig(); 27 | void SaveConfig() const; 28 | 29 | private: 30 | CSize m_min_size{}; //窗口的最小大小(以 96dpi 的大小保存) 31 | CSize m_window_size{ -1, -1 }; 32 | static std::map m_unique_hwnd; //针对每一个基类的唯一的窗口句柄 33 | 34 | protected: 35 | virtual CString GetDialogName() const = 0; 36 | void EnableDlgCtrl(UINT id, bool enable); 37 | 38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 39 | 40 | DECLARE_MESSAGE_MAP() 41 | public: 42 | virtual BOOL OnInitDialog(); 43 | afx_msg void OnDestroy(); 44 | afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); 45 | afx_msg void OnSize(UINT nType, int cx, int cy); 46 | virtual INT_PTR DoModal(); 47 | }; 48 | -------------------------------------------------------------------------------- /TrafficMonitor/DllFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DllFunctions.h" 3 | 4 | CDllFunctions::CDllFunctions() 5 | { 6 | // shellscalingapi 7 | m_shcore_module = ::LoadLibrary(_T("Shcore.dll")); 8 | if (m_shcore_module != NULL) 9 | { 10 | m_getDpiForMonitor = (_GetDpiForMonitor)::GetProcAddress(m_shcore_module, "GetDpiForMonitor"); 11 | } 12 | } 13 | 14 | CDllFunctions::~CDllFunctions() 15 | { 16 | if (m_shcore_module != NULL) 17 | { 18 | FreeLibrary(m_shcore_module); 19 | m_shcore_module = NULL; 20 | } 21 | } 22 | 23 | HRESULT CDllFunctions::GetDpiForMonitor(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT* dpiX, UINT* dpiY) 24 | { 25 | if (m_getDpiForMonitor != nullptr) 26 | return m_getDpiForMonitor(hmonitor, dpiType, dpiX, dpiY); 27 | return 0; 28 | } 29 | 30 | #define TRAFFICMONITOR_DEFINE_STATIC_MEMBER_IN_DLL_FUNCTIONS(member_name, ...) \ 31 | decltype(CDllFunctions::member_name) CDllFunctions::member_name(__VA_ARGS__) 32 | 33 | TRAFFICMONITOR_DEFINE_STATIC_MEMBER_IN_DLL_FUNCTIONS( 34 | D3DCompile, 35 | _T("d3dcompiler_47.dll"), "D3DCompile"); 36 | 37 | TRAFFICMONITOR_DEFINE_STATIC_MEMBER_IN_DLL_FUNCTIONS( 38 | DCompositionCreateDevice, 39 | _T("dcomp.dll"), "DCompositionCreateDevice"); 40 | 41 | TRAFFICMONITOR_DEFINE_STATIC_MEMBER_IN_DLL_FUNCTIONS( 42 | CreateDXGIFactory2, 43 | _T("dxgi.dll"), "CreateDXGIFactory2"); -------------------------------------------------------------------------------- /include/OpenHardwareMonitor/OpenHardwareMonitorApi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "OpenHardwareMonitorGlobal.h" 4 | #include 5 | #include 6 | 7 | namespace OpenHardwareMonitorApi 8 | { 9 | class IOpenHardwareMonitor 10 | { 11 | public: 12 | virtual void GetHardwareInfo() = 0; //获取一次硬件信息 13 | virtual float CpuTemperature() = 0; //返回获取到的CPU温度 14 | virtual float GpuTemperature() = 0; //返回获取到的GPU温度 15 | virtual float HDDTemperature() = 0; //返回获取到的硬盘温度 16 | virtual float MainboardTemperature() = 0; //返回获取到的主板温度 17 | virtual float GpuUsage() = 0; //返回获取到的GPU利用率 18 | virtual float CpuFreq() = 0; //返回获取到的CPU频率 19 | virtual const std::map& AllHDDTemperature() = 0; //返回所有硬盘的温度。map的key是硬盘的名称,value是硬盘的温度 20 | virtual const std::map& AllCpuTemperature() = 0; //返回所有CPU(核心)的温度。map的key是CPU的名称,value是硬盘的温度 21 | virtual const std::map& AllHDDUsage() = 0; //返回所有硬盘的使用率 22 | 23 | virtual void SetCpuEnable(bool enable) = 0; 24 | virtual void SetGpuEnable(bool enable) = 0; 25 | virtual void SetHddEnable(bool enable) = 0; 26 | virtual void SetMainboardEnable(bool enable) = 0; 27 | }; 28 | 29 | OPENHARDWAREMONITOR_API std::shared_ptr CreateInstance(); 30 | OPENHARDWAREMONITOR_API std::wstring GetErrorMessage(); 31 | } 32 | -------------------------------------------------------------------------------- /TrafficMonitor/MessageDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | 4 | // CMessageDlg 对话框 5 | 6 | class CMessageDlg : public CDialog 7 | { 8 | DECLARE_DYNAMIC(CMessageDlg) 9 | 10 | public: 11 | CMessageDlg(CWnd* pParent = NULL); // 标准构造函数 12 | virtual ~CMessageDlg(); 13 | 14 | void SetWindowTitle(LPCTSTR str); 15 | void SetInfoText(LPCTSTR str); 16 | void SetMessageText(LPCTSTR str); 17 | //void ShowLinkStatic(bool show = true) { m_show_link_ctrl = show; } 18 | //void SetLinkInfo(LPCTSTR text, LPCTSTR url); 19 | void SetMessageIcon(HICON hIcon); 20 | 21 | // 对话框数据 22 | #ifdef AFX_DESIGN_TIME 23 | enum { IDD = IDD_MESSAGE_DIALOG }; 24 | #endif 25 | 26 | protected: 27 | CEdit m_message_edit; 28 | CSize m_min_size; //窗口的最小大小 29 | CStatic m_info_static; 30 | 31 | CString m_title; 32 | CString m_info; 33 | CString m_message; 34 | 35 | //CString m_link_text; 36 | //CString m_link_url; 37 | 38 | HICON m_icon{}; 39 | CPoint m_icon_pos{}; //图标的位置 40 | CRect m_rc_info{}; //错误信息Static控件的初始区域 41 | 42 | //bool m_show_link_ctrl{ false }; 43 | 44 | protected: 45 | void SetInfoStaticSize(int cx); //如果设置了图标,则需要将错误信息Static控件向右移动一些 46 | 47 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 48 | 49 | DECLARE_MESSAGE_MAP() 50 | 51 | public: 52 | virtual BOOL OnInitDialog(); 53 | afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); 54 | //afx_msg void OnNMClickSyslink1(NMHDR *pNMHDR, LRESULT *pResult); 55 | afx_msg void OnPaint(); 56 | afx_msg void OnSize(UINT nType, int cx, int cy); 57 | }; 58 | -------------------------------------------------------------------------------- /TrafficMonitor/IconSelectDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include "PictureStatic.h" 4 | #include "BaseDialog.h" 5 | 6 | // CIconSelectDlg 对话框 7 | 8 | class CIconSelectDlg : public CBaseDialog 9 | { 10 | DECLARE_DYNAMIC(CIconSelectDlg) 11 | 12 | public: 13 | CIconSelectDlg(int icon_selected, CWnd* pParent = NULL); // 标准构造函数 14 | virtual ~CIconSelectDlg(); 15 | 16 | int GetIconSelected() const; 17 | 18 | void SetAutoAdaptNotifyIcon(bool val); 19 | bool AutoAdaptNotifyIcon() const; 20 | 21 | // 对话框数据 22 | #ifdef AFX_DESIGN_TIME 23 | enum { IDD = IDD_ICON_SELECT_DIALOG }; 24 | #endif 25 | 26 | #define PREVIEW_WIDTH theApp.DPI(200) //预览图的宽高 27 | #define PREVIEW_HEIGHT theApp.DPI(40) 28 | 29 | #define ICON_X theApp.DPI(46) //预览图中图标的位置 30 | #define ICON_Y theApp.DPI(12) 31 | 32 | protected: 33 | CPictureStatic m_preview_pic; 34 | CComboBox m_icon_select_combo; 35 | CButton m_auto_adapt_chk; 36 | 37 | int m_icon_selected{}; 38 | 39 | bool m_atuo_adapt_notify_icon; 40 | 41 | protected: 42 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 43 | virtual CString GetDialogName() const override; 44 | 45 | void DrawPreviewIcon(CDC* pDC); 46 | 47 | DECLARE_MESSAGE_MAP() 48 | public: 49 | virtual BOOL OnInitDialog(); 50 | //afx_msg void OnTimer(UINT_PTR nIDEvent); 51 | afx_msg void OnCbnSelchangeCombo1(); 52 | protected: 53 | afx_msg LRESULT OnControlRepaint(WPARAM wParam, LPARAM lParam); 54 | public: 55 | afx_msg void OnBnClickedAutoAdaptCheck(); 56 | }; 57 | -------------------------------------------------------------------------------- /TrafficMonitor/CSkinPreviewView.cpp: -------------------------------------------------------------------------------- 1 | // CSkinPreviewView.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "CSkinPreviewView.h" 7 | 8 | 9 | // CSkinPreviewView 10 | 11 | IMPLEMENT_DYNCREATE(CSkinPreviewView, CScrollView) 12 | 13 | CSkinPreviewView::CSkinPreviewView() 14 | { 15 | 16 | } 17 | 18 | CSkinPreviewView::~CSkinPreviewView() 19 | { 20 | } 21 | 22 | 23 | BEGIN_MESSAGE_MAP(CSkinPreviewView, CScrollView) 24 | END_MESSAGE_MAP() 25 | 26 | 27 | // CSkinPreviewView 绘图 28 | 29 | void CSkinPreviewView::OnInitialUpdate() 30 | { 31 | CScrollView::OnInitialUpdate(); 32 | 33 | CSize sizeTotal; 34 | // TODO: 计算此视图的合计大小 35 | m_size.cx = 0; 36 | m_size.cy = 0; 37 | SetScrollSizes(MM_TEXT, m_size); 38 | 39 | 40 | } 41 | 42 | void CSkinPreviewView::OnDraw(CDC* pDC) 43 | { 44 | CDocument* pDoc = GetDocument(); 45 | // TODO: 在此添加绘制代码 46 | CRect draw_rect(CPoint(0, 0), m_size); 47 | m_skin_data->DrawPreview(pDC, draw_rect); 48 | } 49 | 50 | 51 | // CSkinPreviewView 诊断 52 | 53 | //#ifdef _DEBUG 54 | //void CSkinPreviewView::AssertValid() const 55 | //{ 56 | // CScrollView::AssertValid(); 57 | //} 58 | 59 | //#ifndef _WIN32_WCE 60 | //void CSkinPreviewView::Dump(CDumpContext& dc) const 61 | //{ 62 | // CScrollView::Dump(dc); 63 | //} 64 | //#endif 65 | //#endif //_DEBUG 66 | 67 | void CSkinPreviewView::InitialUpdate() 68 | { 69 | OnInitialUpdate(); 70 | } 71 | void CSkinPreviewView::SetSize(int width, int hight) 72 | { 73 | m_size = CSize(width, hight); 74 | SetScrollSizes(MM_TEXT, m_size); 75 | } 76 | 77 | // CSkinPreviewView 消息处理程序 78 | -------------------------------------------------------------------------------- /TrafficMonitor/D2D1Support.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "HResultException.h" 5 | #include "RenderAPISupport.h" 6 | 7 | class CD2D1Exception final : public CHResultException 8 | { 9 | using CHResultException::CHResultException; 10 | }; 11 | 12 | class CDWriteException final : public CHResultException 13 | { 14 | using CHResultException::CHResultException; 15 | }; 16 | 17 | class CD2D1Support 18 | { 19 | public: 20 | #ifdef DEBUG 21 | constexpr static D2D1_FACTORY_OPTIONS CREATION_OPTIONS{D2D1_DEBUG_LEVEL_INFORMATION}; 22 | #else 23 | constexpr static D2D1_FACTORY_OPTIONS CREATION_OPTIONS{D2D1_DEBUG_LEVEL_NONE}; 24 | #endif 25 | 26 | static bool CheckSupport(); 27 | static ID2D1Factory* GetFactory(); 28 | }; 29 | 30 | class CD2D1Device 31 | { 32 | public: 33 | using Type = Microsoft::WRL::ComPtr; 34 | using Resource = CDeviceResource; 35 | using Storage = storage_t>; 36 | 37 | private: 38 | Type m_p_device{}; 39 | CResourceTracker m_resource_tracker{std::make_shared()}; 40 | 41 | public: 42 | void Recreate(Microsoft::WRL::ComPtr p_dxgi_device); 43 | auto GetStorage() 44 | -> std::shared_ptr; 45 | Type Get(); 46 | }; 47 | 48 | class CD2D1Support1 49 | { 50 | public: 51 | static bool CheckSupport(); 52 | static ID2D1Factory1* GetFactory(); 53 | }; 54 | 55 | class CDWriteSupport 56 | { 57 | public: 58 | static bool CheckSupport(); 59 | static IDWriteFactory* GetFactory(); 60 | }; 61 | -------------------------------------------------------------------------------- /TrafficMonitor/DrawCommonFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DrawCommonFactory.h" 3 | 4 | auto GetInterfaceFromAllInvolvedDrawCommonObjects( 5 | AllInvolvedDrawCommonObjectsStorage& ref_object_storage, 6 | DrawCommonHelper::RenderType render_type, 7 | std::initializer_list initializer_list) 8 | -> std::tuple 9 | { 10 | auto& ref_draw_buffer_and_draw_common_objects = *static_cast( 11 | static_cast(std::addressof(ref_object_storage))); 12 | auto p_draw_buffer = static_cast( 13 | static_cast( 14 | std::addressof(ref_draw_buffer_and_draw_common_objects.m_draw_buffer_union_storage))); 15 | auto p_draw_common = static_cast( 16 | static_cast( 17 | std::addressof(ref_draw_buffer_and_draw_common_objects.m_draw_common_union_storage))); 18 | 19 | for (auto& initializer : initializer_list) 20 | { 21 | if (initializer.first == render_type) 22 | { 23 | initializer.second(p_draw_buffer, p_draw_common); 24 | 25 | UniqueIDrawBuffer up_draw_buffer{p_draw_buffer}; 26 | ref_object_storage.m_unique_draw_buffer.swap(up_draw_buffer); 27 | UniqueIDrawCommon up_draw_common{p_draw_common}; 28 | ref_object_storage.m_unique_draw_common.swap(up_draw_common); 29 | return {p_draw_buffer, p_draw_common}; 30 | } 31 | } 32 | throw std::runtime_error{TRAFFICMONITOR_ERROR_STR("No matching render type for initializer")}; 33 | } -------------------------------------------------------------------------------- /TrafficMonitor/SkinDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include"StaticEx.h" 4 | #include "PictureStatic.h" 5 | #include "CSkinPreviewView.h" 6 | #include "LinkStatic.h" 7 | #include "BaseDialog.h" 8 | 9 | // CSkinDlg 对话框 10 | 11 | class CSkinDlg : public CBaseDialog 12 | { 13 | DECLARE_DYNAMIC(CSkinDlg) 14 | 15 | public: 16 | CSkinDlg(CWnd* pParent = NULL); // 标准构造函数 17 | virtual ~CSkinDlg(); 18 | 19 | vector m_skins; //皮肤文件的路径 20 | int m_skin_selected; //选择的皮肤 21 | CFont* m_pFont; //预览图的字体 22 | 23 | // 对话框数据 24 | #ifdef AFX_DESIGN_TIME 25 | enum { IDD = IDD_SKIN_DIALOG }; 26 | #endif 27 | 28 | const CSkinFile& GetSkinData() const { return m_skin_data; } 29 | 30 | protected: 31 | virtual CString GetDialogName() const override; 32 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 33 | 34 | protected: 35 | //控件变量 36 | CComboBox m_select_box; //选择框 37 | CLinkStatic m_skin_course; //“皮肤制作教程”超链接 38 | CLinkStatic m_skin_download; //“更多皮肤下载”超链接 39 | CLinkStatic m_open_skin_dir_lnk; 40 | CSkinPreviewView* m_view; //预览区视图类 41 | CStatic m_preview_static; 42 | CStaticEx m_notify_static; //显示提示信息的static控件 43 | 44 | CSkinFile m_skin_data; //皮肤数据 45 | 46 | void ShowPreview(); //显示皮肤预览 47 | CRect CalculateViewRect(); //根据窗口大小计算预览视图的大小 48 | 49 | DECLARE_MESSAGE_MAP() 50 | public: 51 | virtual BOOL OnInitDialog(); 52 | afx_msg void OnCbnSelchangeCombo1(); 53 | afx_msg void OnSize(UINT nType, int cx, int cy); 54 | protected: 55 | afx_msg LRESULT OnLinkClicked(WPARAM wParam, LPARAM lParam); 56 | }; 57 | -------------------------------------------------------------------------------- /TrafficMonitor/CalendarHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CalendarHelper.h" 3 | 4 | 5 | CCalendarHelper::CCalendarHelper() 6 | { 7 | } 8 | 9 | 10 | CCalendarHelper::~CCalendarHelper() 11 | { 12 | } 13 | 14 | bool CCalendarHelper::IsLeapYear(int year) 15 | { 16 | return ((0 == year % 4 && 0 != year % 100) || 0 == year % 400); 17 | } 18 | 19 | int CCalendarHelper::CaculateWeekDay(int y, int m, int d) 20 | { 21 | if (m <= 2) 22 | { 23 | m += 12; 24 | y--; 25 | } 26 | return (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7; 27 | } 28 | 29 | int CCalendarHelper::DaysInMonth(int year, int month) 30 | { 31 | bool leap{ IsLeapYear(year) }; 32 | switch (month) 33 | { 34 | case 2: 35 | if (leap) return 29; 36 | else return 28; 37 | case 4: case 6: case 9: case 11: 38 | return 30; 39 | default: 40 | return 31; 41 | } 42 | } 43 | 44 | void CCalendarHelper::GetCalendar(int year, int month, DayTraffic calendar[CALENDAR_HEIGHT][CALENDAR_WIDTH], bool sunday_first) 45 | { 46 | memset(calendar, 0, sizeof(DayTraffic)*CALENDAR_HEIGHT*CALENDAR_WIDTH); 47 | int days{ DaysInMonth(year, month) }; 48 | int first_weak_day{ CaculateWeekDay(year, month, 1) }; 49 | if(!sunday_first) 50 | { 51 | first_weak_day--; 52 | if (first_weak_day < 0) 53 | first_weak_day = 6; 54 | } 55 | int i{}, j{}; 56 | for (int n{}; n < 37; n++) 57 | { 58 | if (n < first_weak_day) 59 | { 60 | calendar[i][j].day = 0; 61 | } 62 | else 63 | { 64 | int day = n - first_weak_day + 1; 65 | if (day <= days) 66 | calendar[i][j].day = day; 67 | } 68 | j++; 69 | if (j >= 7) 70 | { 71 | j = 0; 72 | i++; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /TrafficMonitor/AboutDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DonateDlg.h" 3 | #include "LinkStatic.h" 4 | #include "BaseDialog.h" 5 | 6 | // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 7 | 8 | class CAboutDlg : public CBaseDialog 9 | { 10 | public: 11 | CAboutDlg(); 12 | 13 | // 对话框数据 14 | #ifdef AFX_DESIGN_TIME 15 | enum { IDD = IDD_ABOUTBOX }; 16 | #endif 17 | 18 | protected: 19 | CLinkStatic m_mail; //“联系作者”超链接 20 | CLinkStatic m_acknowledgement; //“鸣谢”超链接 21 | CLinkStatic m_github; //“GitHub”超链接 22 | CLinkStatic m_gitee; //“Gitee”超链接 23 | CLinkStatic m_donate; //“捐助”超链接 24 | CLinkStatic m_license; //“开源协议”超链接 25 | CToolTipCtrl m_tool_tip; //鼠标指向时的工具提示 26 | CLinkStatic m_translaotr_static; 27 | CLinkStatic m_openhardwaremonitor_link; 28 | CLinkStatic m_tinyxml2_link; 29 | CLinkStatic m_musicplayer2_link; 30 | CLinkStatic m_simplenotepad_link; 31 | 32 | CRect m_rc_pic; //图片的位置 33 | CBitmap m_about_pic; 34 | 35 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 36 | CString GetDonateList(); //从资源文件加载捐赠人员名单 37 | virtual CString GetDialogName() const override; 38 | 39 | // 实现 40 | protected: 41 | DECLARE_MESSAGE_MAP() 42 | public: 43 | virtual BOOL OnInitDialog(); 44 | virtual BOOL PreTranslateMessage(MSG* pMsg); 45 | // afx_msg void OnStnClickedStaticDonate(); 46 | protected: 47 | afx_msg LRESULT OnLinkClicked(WPARAM wParam, LPARAM lParam); 48 | public: 49 | afx_msg void OnPaint(); 50 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 51 | afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); 52 | }; 53 | -------------------------------------------------------------------------------- /TrafficMonitor/PluginInfoDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BaseDialog.h" 3 | #include "ListCtrlEx.h" 4 | 5 | // CPluginInfoDlg 对话框 6 | 7 | class CPluginInfoDlg : public CBaseDialog 8 | { 9 | DECLARE_DYNAMIC(CPluginInfoDlg) 10 | 11 | public: 12 | CPluginInfoDlg(int plugin_index, CWnd* pParent = nullptr); // 标准构造函数 13 | virtual ~CPluginInfoDlg(); 14 | 15 | // 对话框数据 16 | #ifdef AFX_DESIGN_TIME 17 | enum { IDD = IDD_NETWORK_INFO_DIALOG }; 18 | #endif 19 | 20 | private: 21 | int m_cur_index; //初始显示的插件索引 22 | CListCtrlEx m_info_list; 23 | CMenu m_menu; 24 | CString m_selected_string; 25 | 26 | //列表中的列 27 | enum RowIndex 28 | { 29 | RI_FILE_NAME, 30 | RI_FILE_PATH, 31 | RI_NAME, 32 | RI_DESCRIPTION, 33 | RI_ITEM_NUM, 34 | RI_ITEM_NAMES, 35 | RI_ITEM_ID, 36 | RI_AUTHOR, 37 | RI_COPYRIGHT, 38 | RI_URL, 39 | RI_VERSION, 40 | RI_API_VERSION, 41 | RI_MAX 42 | }; 43 | 44 | protected: 45 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 46 | void ShowInfo(); 47 | static CString GetRowName(int row_index); //获取行的名称 48 | 49 | // 通过 CBaseDialog 继承 50 | virtual CString GetDialogName() const override; 51 | 52 | DECLARE_MESSAGE_MAP() 53 | public: 54 | virtual BOOL OnInitDialog(); 55 | 56 | afx_msg void OnCopyText(); 57 | afx_msg void OnNMRClickInfoList1(NMHDR* pNMHDR, LRESULT* pResult); 58 | afx_msg void OnBnClickedPreviousButton(); 59 | afx_msg void OnBnClickedNextButton(); 60 | virtual BOOL PreTranslateMessage(MSG* pMsg); 61 | afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /TrafficMonitor/HighResolutionTimer.h: -------------------------------------------------------------------------------- 1 | #include 2 | #pragma comment(lib, "WINMM.LIB") 3 | 4 | class CHighResolutionTimer 5 | { 6 | typedef void(*TIMERCALLBACK)(DWORD_PTR); 7 | 8 | private: 9 | DWORD_PTR m_dwUser; 10 | MMRESULT m_nIDTimer; 11 | UINT m_uDelay; 12 | TIMERCALLBACK m_pfnCallback; 13 | 14 | public: 15 | void KillTimer() 16 | { 17 | if (m_nIDTimer != NULL) 18 | { 19 | timeKillEvent(m_nIDTimer); 20 | m_nIDTimer = NULL; 21 | } 22 | } 23 | 24 | CHighResolutionTimer() 25 | { 26 | m_nIDTimer = NULL; 27 | m_uDelay = 0; 28 | m_pfnCallback = 0; 29 | } 30 | 31 | virtual ~CHighResolutionTimer() 32 | { 33 | KillTimer(); 34 | } 35 | 36 | static void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) 37 | { 38 | // dwUser contains ptr to Timer object 39 | CHighResolutionTimer * ptimer = (CHighResolutionTimer *)dwUser; 40 | // Call user-specified callback and pass back user specified data 41 | (ptimer->m_pfnCallback) (ptimer->m_dwUser); 42 | } 43 | 44 | BOOL CreateTimer(DWORD_PTR dwUser, UINT uDelay, TIMERCALLBACK lpTimeProc) 45 | { 46 | ASSERT(dwUser); 47 | ASSERT(lpTimeProc); 48 | 49 | m_dwUser = dwUser; 50 | m_pfnCallback = lpTimeProc; 51 | BOOL ret = FALSE; 52 | KillTimer(); 53 | m_nIDTimer = timeSetEvent(uDelay, 0, (LPTIMECALLBACK)TimeProc, (DWORD_PTR)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); 54 | 55 | if (m_nIDTimer != NULL) 56 | ret = TRUE; 57 | return(ret); 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /TrafficMonitor/PluginManagerDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BaseDialog.h" 3 | #include "LinkStatic.h" 4 | #include "ListCtrlEx.h" 5 | 6 | // CPluginManagerDlg 对话框 7 | 8 | class CPluginManagerDlg : public CBaseDialog 9 | { 10 | DECLARE_DYNAMIC(CPluginManagerDlg) 11 | 12 | public: 13 | CPluginManagerDlg(CWnd* pParent = nullptr); // 标准构造函数 14 | virtual ~CPluginManagerDlg(); 15 | 16 | // 对话框数据 17 | #ifdef AFX_DESIGN_TIME 18 | enum { IDD = IDD_PLUGIN_MANAGER_DIALOG }; 19 | #endif 20 | 21 | private: 22 | CListCtrlEx m_list_ctrl; 23 | int m_item_selected{ -1 }; 24 | CMenu m_menu; 25 | CLinkStatic m_plugin_download_lnk; 26 | CLinkStatic m_plugin_dev_guide_lnk; 27 | CLinkStatic m_open_plugin_dir_lnk; 28 | CImageList m_plugin_icon_list; 29 | 30 | protected: 31 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 32 | void EnableControl(); 33 | bool IsSelectedValid(); 34 | bool IsSelectedPluginEnable(); //选中插件是否可用 35 | 36 | DECLARE_MESSAGE_MAP() 37 | 38 | // 通过 CBaseDialog 继承 39 | virtual CString GetDialogName() const override; 40 | public: 41 | virtual BOOL OnInitDialog(); 42 | afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult); 43 | afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult); 44 | afx_msg void OnBnClickedOptinsButton(); 45 | afx_msg void OnBnClickedPluginInfoButton(); 46 | afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult); 47 | afx_msg void OnInitMenu(CMenu* pMenu); 48 | afx_msg void OnPluginDetail(); 49 | afx_msg void OnPluginOptions(); 50 | afx_msg void OnPluginDisable(); 51 | protected: 52 | afx_msg LRESULT OnLinkClicked(WPARAM wParam, LPARAM lParam); 53 | }; 54 | -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : OpenHardwareMonitorApi Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this OpenHardwareMonitorApi DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your OpenHardwareMonitorApi application. 9 | 10 | OpenHardwareMonitorApi.vcxproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | OpenHardwareMonitorApi.vcxproj.filters 17 | This is the filters file for VC++ projects generated using an Application Wizard. 18 | It contains information about the association between the files in your project 19 | and the filters. This association is used in the IDE to show grouping of files with 20 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 21 | "Source Files" filter). 22 | 23 | OpenHardwareMonitorApi.cpp 24 | This is the main DLL source file. 25 | 26 | OpenHardwareMonitorApi.h 27 | This file contains a class declaration. 28 | 29 | AssemblyInfo.cpp 30 | Contains custom attributes for modifying assembly metadata. 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | Other notes: 34 | 35 | AppWizard uses "TODO:" to indicate parts of the source code you 36 | should add to or customize. 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | -------------------------------------------------------------------------------- /TrafficMonitor/SpinEdit.cpp: -------------------------------------------------------------------------------- 1 | // SpinEdit.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "SpinEdit.h" 6 | 7 | 8 | // CSpinEdit 9 | 10 | IMPLEMENT_DYNAMIC(CSpinEdit, CEdit) 11 | 12 | CSpinEdit::CSpinEdit() 13 | { 14 | 15 | } 16 | 17 | CSpinEdit::~CSpinEdit() 18 | { 19 | } 20 | 21 | void CSpinEdit::SetRange(short lower, short upper) 22 | { 23 | if (m_spin.GetSafeHwnd() != NULL) 24 | m_spin.SetRange(lower, upper); 25 | } 26 | 27 | void CSpinEdit::SetValue(int value) 28 | { 29 | if (m_spin.GetSafeHwnd() != NULL) 30 | m_spin.SetPos(value); 31 | } 32 | 33 | int CSpinEdit::GetValue() 34 | { 35 | if (m_spin.GetSafeHwnd() != NULL) 36 | return m_spin.GetPos32(); 37 | else 38 | return 0; 39 | } 40 | 41 | 42 | void CSpinEdit::SetMouseWheelEnable(bool enable) 43 | { 44 | m_mouse_wheel_enable = enable; 45 | } 46 | 47 | BEGIN_MESSAGE_MAP(CSpinEdit, CEdit) 48 | END_MESSAGE_MAP() 49 | 50 | 51 | 52 | // CSpinEdit 消息处理程序 53 | 54 | void CSpinEdit::PreSubclassWindow() 55 | { 56 | // TODO: 在此添加专用代码和/或调用基类 57 | CWnd* pParent = GetParent(); //获取控件的父窗口 58 | m_spin.Create(UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_SETBUDDYINT | WS_VISIBLE, CRect(), pParent, SPIN_ID); //创建微调控件 59 | m_spin.SetBuddy(this); //设置Edit控件为关联控件 60 | m_spin.SetRange(0, 999); //设置默认范围 61 | 62 | CEdit::PreSubclassWindow(); 63 | } 64 | 65 | 66 | BOOL CSpinEdit::PreTranslateMessage(MSG* pMsg) 67 | { 68 | // TODO: 在此添加专用代码和/或调用基类 69 | 70 | //如果m_mouse_wheel_enable为false,则不响应鼠标滚轮消息 71 | if (pMsg->message == WM_MOUSEWHEEL && !m_mouse_wheel_enable) 72 | { 73 | //将鼠标滚轮消息发送给父窗口 74 | CWnd* pParent = GetParent(); 75 | pParent->SendMessage(WM_MOUSEWHEEL, pMsg->wParam, pMsg->lParam); 76 | return true; 77 | } 78 | 79 | return CEdit::PreTranslateMessage(pMsg); 80 | } 81 | -------------------------------------------------------------------------------- /TrafficMonitor/HResultException.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #define TRAFFICMONITOR_STR_IMPL(x) #x 6 | #define TRAFFICMONITOR_STR(x) TRAFFICMONITOR_STR_IMPL(x) 7 | 8 | #define TRAFFICMONITOR_ERROR_STR(x) \ 9 | "At file: " TRAFFICMONITOR_STR(__FILE__) " | line: " TRAFFICMONITOR_STR(__LINE__) ".\nError: " x 10 | 11 | #define RELEASE_COM(p) \ 12 | { \ 13 | if (p) \ 14 | { \ 15 | (p)->Release(); \ 16 | (p) = (NULL); \ 17 | } \ 18 | } 19 | 20 | namespace FunctionChecker 21 | { 22 | bool CheckLibraryExist(LPCTSTR p_library_name) noexcept; 23 | bool CheckFunctionExist(LPCTSTR p_library_name, LPCSTR p_function_name) noexcept; 24 | } 25 | 26 | class CHResultException : public std::runtime_error 27 | { 28 | public: 29 | CHResultException(HRESULT hr, const char* p_message); 30 | ~CHResultException() override = default; 31 | 32 | auto GetError() 33 | -> Microsoft::WRL::ComPtr; 34 | bool HasError() const noexcept; 35 | auto GetHResult() const noexcept 36 | -> HRESULT; 37 | 38 | private: 39 | Microsoft::WRL::ComPtr m_p_error; 40 | HRESULT m_hr; 41 | HRESULT m_get_p_error_hr; 42 | }; 43 | 44 | extern const char* const ERROR_WHEN_CALL_COM_FUNCTION; /*The content should be "Error occurred when call COM function." */ 45 | void ThrowIfFailed(HRESULT hr, const char* p_message = ERROR_WHEN_CALL_COM_FUNCTION); 46 | template 47 | void ThrowIfFailed(HRESULT hr, const char* p_message, Args... args) 48 | { 49 | if (FAILED(hr)) 50 | { 51 | throw Exception{hr, p_message, std::forward(args)...}; 52 | } 53 | } 54 | 55 | void LogHResultException(CHResultException& ex); 56 | -------------------------------------------------------------------------------- /TrafficMonitor/Dxgi1Support2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "HResultException.h" 4 | #include "RenderAPISupport.h" 5 | 6 | #pragma comment(lib, "DXGI.lib") 7 | 8 | class CDxgiException final : public CHResultException 9 | { 10 | using CHResultException::CHResultException; 11 | }; 12 | 13 | template 14 | class CDxgiSwapChainResource : public CDeviceResourceBase 15 | { 16 | public: 17 | using Base = CDeviceResourceBase; 18 | using Base::Base; 19 | using typename Base::DeviceType; 20 | 21 | /** 22 | * @brief 在准备Resize交换链时,此函数将被调用,用于释放所有和交换链相关的资源。\n 23 | 注意:此函数可能被多次调用,且调用次数不一定与OnSwapChainResizeEnd的次数相匹配, 24 | 因此必须保证资源可以被反复执行释放操作 25 | * 26 | */ 27 | virtual void OnSwapChainResizeBegin() noexcept = 0; 28 | /** 29 | * @brief 在交换链完成Resize后,此函数将被调用,用于重建所有和交换链相关的资源 30 | * 31 | */ 32 | virtual void OnSwapChainResizeEnd(DeviceType p_resized_swap_chain) noexcept = 0; 33 | }; 34 | 35 | /** 36 | * @brief 此类对应的资源为CDxgiSwapChainResource,而非CDeviceResource 37 | * 38 | */ 39 | class CDxgiSwapChain1 40 | { 41 | public: 42 | using Resource = CDxgiSwapChainResource; 43 | using Type = Microsoft::WRL::ComPtr; 44 | using Storage = storage_t>; 45 | 46 | private: 47 | Type m_p_swap_chain1{}; 48 | CResourceTracker m_resource_tracker{std::make_shared()}; 49 | 50 | public: 51 | void Recreate(Microsoft::WRL::ComPtr p_device, const DXGI_SWAP_CHAIN_DESC1& ref_desc1, IDXGIOutput* p_output = nullptr); 52 | auto GetStorage() 53 | -> std::shared_ptr; 54 | void Resize(std::uint32_t width, std::uint32_t height); 55 | }; 56 | 57 | class CDxgi1Support2 58 | { 59 | public: 60 | static bool CheckSupport(); 61 | static IDXGIFactory2* GetFactory(); 62 | }; 63 | -------------------------------------------------------------------------------- /TrafficMonitor/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Test.h" 3 | #include "Common.h" 4 | #include "SkinFile.h" 5 | #include "TrafficMonitor.h" 6 | 7 | CTest::CTest() 8 | { 9 | } 10 | 11 | CTest::~CTest() 12 | { 13 | } 14 | 15 | void CTest::Test() 16 | { 17 | //TestHttpQequest(); 18 | //TestGetLicense(); 19 | //TestSkin(); 20 | //TestCrash(); 21 | //TestDate(); 22 | } 23 | 24 | void CTest::TestCommand() 25 | { 26 | //TestPlugin(); 27 | } 28 | 29 | void CTest::TestHttpQequest() 30 | { 31 | wstring result; 32 | bool rtn = CCommon::GetURL(L"https://v4.yinghualuo.cn/bejson", result, true, L"TrafficMonitor_V1.78"); 33 | int a = 0; 34 | } 35 | 36 | void CTest::TestGetLicense() 37 | { 38 | CString license_str; 39 | HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_LICENSE), _T("TEXT")); 40 | if (hRes != NULL) 41 | { 42 | HGLOBAL hglobal = LoadResource(NULL, hRes); 43 | if (hglobal != NULL) 44 | { 45 | license_str = CCommon::StrToUnicode((const char*)hglobal, true).c_str(); 46 | int a = 0; 47 | } 48 | } 49 | } 50 | 51 | void CTest::TestSkin() 52 | { 53 | CSkinFile skin; 54 | //skin.Load(L"C:\\Users\\zhong\\OneDrive\\文档\\TrafficMonitorSkin.xml"); 55 | skin.Load(L"D:\\Projects\\GitHub Project\\TrafficMonitor\\TrafficMonitor\\skins\\0默认皮肤\\skin.ini"); 56 | int a = 0; 57 | } 58 | 59 | void CTest::TestCrash() 60 | { 61 | CString* pStr = nullptr; 62 | int a = pStr->GetLength(); 63 | printf("%d", a); 64 | 65 | } 66 | 67 | void CTest::TestPlugin() 68 | { 69 | if (!theApp.m_plugins.GetPlugins().empty()) 70 | { 71 | theApp.m_plugins.GetPlugins()[0].plugin->ShowOptionsDialog(theApp.m_pMainWnd->m_hWnd); 72 | } 73 | } 74 | 75 | void CTest::TestDate() 76 | { 77 | Date d; 78 | d.year = 2021; 79 | d.month = 1; 80 | d.day = 4; 81 | int week = d.week(); 82 | int a = 0; 83 | } 84 | -------------------------------------------------------------------------------- /TrafficMonitor/SetItemOrderDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BaseDialog.h" 3 | 4 | // CSetItemOrderDlg 对话框 5 | 6 | class CSetItemOrderDlg : public CBaseDialog 7 | { 8 | DECLARE_DYNAMIC(CSetItemOrderDlg) 9 | 10 | public: 11 | CSetItemOrderDlg(CWnd* pParent = nullptr); // 标准构造函数 12 | virtual ~CSetItemOrderDlg(); 13 | 14 | //设置/获取显示顺序 15 | void SetItemOrder(const std::vector& item_order); 16 | const std::vector& GetItemOrder() const; 17 | 18 | //设置/获取显示项目,使用unsigned int的每个bit表示对应项目是否显示 19 | void SetDisplayItem(unsigned int display_item); 20 | unsigned int GetDisplayItem() const; 21 | 22 | void SetPluginDisplayItem(const StringSet& plugin_item); 23 | const StringSet& GetPluginDisplayItem() const; 24 | 25 | // 对话框数据 26 | #ifdef AFX_DESIGN_TIME 27 | enum { IDD = IDD_SELECT_ORDER_DIALOG }; 28 | #endif 29 | 30 | private: 31 | CTaskbarItemOrderHelper m_item_order; //显示项目的顺序 32 | CCheckListBox m_list_ctrl; 33 | unsigned int m_display_item; //使用每个bit位表示的要显示的内置项目 34 | StringSet m_plugin_item; //要显示的插件项目 35 | std::vector m_all_displayed_item; //在列表中显示的所有项目 36 | 37 | protected: 38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 39 | void ShowItem(); 40 | void EnableCtrl(int list_selected); 41 | void EnableDlgCtrl(UINT id, bool enable); 42 | 43 | bool GetItemChecked(CommonDisplayItem item); 44 | void SaveItemChecked(CommonDisplayItem item, bool checked); 45 | 46 | // 通过 CBaseDialog 继承 47 | virtual CString GetDialogName() const override; 48 | 49 | DECLARE_MESSAGE_MAP() 50 | public: 51 | virtual BOOL OnInitDialog(); 52 | afx_msg void OnBnClickedMoveUpButton(); 53 | afx_msg void OnBnClickedMoveDownButton(); 54 | afx_msg void OnBnClickedRestoreDefaultButton(); 55 | afx_msg void OnLbnSelchangeList1(); 56 | afx_msg void OnCheckChanged(); 57 | virtual void OnOK(); 58 | }; 59 | -------------------------------------------------------------------------------- /TrafficMonitor/skins/xml_test/skin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16768959,10022341,16777215,16777215,16777215,16770992,16770992,16770992,16770992 4 | 1 5 | zy 6 | 7 | 8 | 上传: 9 | 下载: 10 | CPU: 11 | 内存: 12 | 显卡: 13 | CPU温度: 14 | 显卡温度: 15 | ↑↓: 16 | 17 | 18 | 19 | 20 | b4zc373y 21 | b5R30ITQ 22 | NdKZEf39 23 | W5XuBvH0 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /TrafficMonitor/TinyXml2Helper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "TinyXml2Helper.h" 3 | #include "Common.h" 4 | 5 | bool CTinyXml2Helper::LoadXmlFile(tinyxml2::XMLDocument& doc, const wchar_t* file_path) 6 | { 7 | //由于XMLDocument::LoadFile函数不支持Unicode,因此这里自行读取文件内容,并调用XMLDocument::Parse函数解析 8 | size_t length; 9 | const char* xml_contents = CCommon::GetFileContent(file_path, length); 10 | auto err = doc.Parse(xml_contents, length); 11 | delete[] xml_contents; 12 | return err == tinyxml2::XML_SUCCESS; 13 | } 14 | 15 | void CTinyXml2Helper::IterateChildNode(tinyxml2::XMLElement* ele, std::function fun) 16 | { 17 | if (ele == nullptr) 18 | return; 19 | 20 | tinyxml2::XMLElement* child = ele->FirstChildElement(); 21 | if (child == nullptr) 22 | return; 23 | fun(child); 24 | while (true) 25 | { 26 | child = child->NextSiblingElement(); 27 | if (child != nullptr) 28 | fun(child); 29 | else 30 | break; 31 | } 32 | } 33 | 34 | const char * CTinyXml2Helper::ElementAttribute(tinyxml2::XMLElement * ele, const char * attr) 35 | { 36 | if (ele != nullptr) 37 | { 38 | const char* str = ele->Attribute(attr); 39 | if (str != nullptr) 40 | return str; 41 | } 42 | return ""; 43 | } 44 | 45 | const char* CTinyXml2Helper::ElementName(tinyxml2::XMLElement* ele) 46 | { 47 | if (ele != nullptr) 48 | { 49 | const char* str = ele->Name(); 50 | if (str != nullptr) 51 | return str; 52 | } 53 | return ""; 54 | } 55 | 56 | const char* CTinyXml2Helper::ElementText(tinyxml2::XMLElement* ele) 57 | { 58 | if (ele != nullptr) 59 | { 60 | const char* str = ele->GetText(); 61 | if (str != nullptr) 62 | return str; 63 | } 64 | return ""; 65 | } 66 | 67 | bool CTinyXml2Helper::StringToBool(const char* str) 68 | { 69 | string str_text{ str }; 70 | return (!str_text.empty() && str_text != "0"); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/OpenHardwareMonitorApi.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 38 | 39 | 源文件 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 资源文件 54 | 55 | 56 | -------------------------------------------------------------------------------- /PluginDemo/DataManager.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "DataManager.h" 3 | 4 | CDataManager CDataManager::m_instance; 5 | 6 | CDataManager::CDataManager() 7 | { 8 | } 9 | 10 | CDataManager::~CDataManager() 11 | { 12 | SaveConfig(); 13 | } 14 | 15 | CDataManager& CDataManager::Instance() 16 | { 17 | return m_instance; 18 | } 19 | 20 | void CDataManager::LoadConfig(const std::wstring& config_dir) 21 | { 22 | //获取模块的路径 23 | HMODULE hModule = reinterpret_cast(&__ImageBase); 24 | wchar_t path[MAX_PATH]; 25 | GetModuleFileNameW(hModule, path, MAX_PATH); 26 | std::wstring module_path = path; 27 | m_config_path = module_path; 28 | if (!config_dir.empty()) 29 | { 30 | size_t index = module_path.find_last_of(L"\\/"); 31 | //模块的文件名 32 | std::wstring module_file_name = module_path.substr(index + 1); 33 | m_config_path = config_dir + module_file_name; 34 | } 35 | m_config_path += L".ini"; 36 | m_setting_data.show_second = GetPrivateProfileInt(_T("config"), _T("show_second"), 0, m_config_path.c_str()); 37 | //m_setting_data.show_label_text = GetPrivateProfileInt(_T("config"), _T("show_label_text"), 1, config_path.c_str()); 38 | } 39 | 40 | static void WritePrivateProfileInt(const wchar_t* app_name, const wchar_t* key_name, int value, const wchar_t* file_path) 41 | { 42 | wchar_t buff[16]; 43 | swprintf_s(buff, L"%d", value); 44 | WritePrivateProfileString(app_name, key_name, buff, file_path); 45 | } 46 | 47 | void CDataManager::SaveConfig() const 48 | { 49 | WritePrivateProfileInt(_T("config"), _T("show_second"), m_setting_data.show_second, m_config_path.c_str()); 50 | //WritePrivateProfileInt(_T("config"), _T("show_label_text"), m_setting_data.show_label_text, config_path.c_str()); 51 | } 52 | 53 | const CString& CDataManager::StringRes(UINT id) 54 | { 55 | auto iter = m_string_table.find(id); 56 | if (iter != m_string_table.end()) 57 | { 58 | return iter->second; 59 | } 60 | else 61 | { 62 | AFX_MANAGE_STATE(AfxGetStaticModuleState()); 63 | m_string_table[id].LoadString(id); 64 | return m_string_table[id]; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /TrafficMonitor/AppAlreadyRuningDlg.cpp: -------------------------------------------------------------------------------- 1 | // AppAlreadyRuningDlg.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "AppAlreadyRuningDlg.h" 7 | #include "afxdialogex.h" 8 | 9 | 10 | // CAppAlreadyRuningDlg 对话框 11 | 12 | IMPLEMENT_DYNAMIC(CAppAlreadyRuningDlg, CDialog) 13 | 14 | CAppAlreadyRuningDlg::CAppAlreadyRuningDlg(HWND handel, CWnd* pParent /*=nullptr*/) 15 | : CDialog(IDD_APP_ALREAD_RUNING_DIALOG, pParent), m_handle(handel) 16 | { 17 | 18 | } 19 | 20 | CAppAlreadyRuningDlg::~CAppAlreadyRuningDlg() 21 | { 22 | } 23 | 24 | void CAppAlreadyRuningDlg::DoDataExchange(CDataExchange* pDX) 25 | { 26 | CDialog::DoDataExchange(pDX); 27 | } 28 | 29 | 30 | BEGIN_MESSAGE_MAP(CAppAlreadyRuningDlg, CDialog) 31 | ON_BN_CLICKED(IDC_EXIT_INST_BUTTON, &CAppAlreadyRuningDlg::OnBnClickedExitInstButton) 32 | ON_BN_CLICKED(IDC_OPEN_SETTINGS_BUTTON, &CAppAlreadyRuningDlg::OnBnClickedOpenSettingsButton) 33 | ON_BN_CLICKED(IDC_SHOW_HIDE_MAIN_WINDOW_BUTTON, &CAppAlreadyRuningDlg::OnBnClickedShowHideMainWindowButton) 34 | ON_BN_CLICKED(IDC_SHOW_HIDE_TASKBAR_WINDOW_BUTTON, &CAppAlreadyRuningDlg::OnBnClickedShowHideTaskbarWindowButton) 35 | END_MESSAGE_MAP() 36 | 37 | 38 | // CAppAlreadyRuningDlg 消息处理程序 39 | 40 | 41 | BOOL CAppAlreadyRuningDlg::OnInitDialog() 42 | { 43 | CDialog::OnInitDialog(); 44 | 45 | // TODO: 在此添加额外的初始化 46 | SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE); 47 | 48 | return TRUE; // return TRUE unless you set the focus to a control 49 | // 异常: OCX 属性页应返回 FALSE 50 | } 51 | 52 | 53 | void CAppAlreadyRuningDlg::OnBnClickedExitInstButton() 54 | { 55 | ::PostMessage(m_handle, WM_COMMAND, ID_APP_EXIT, 0); 56 | } 57 | 58 | 59 | void CAppAlreadyRuningDlg::OnBnClickedOpenSettingsButton() 60 | { 61 | ::PostMessage(m_handle, WM_COMMAND, ID_OPTIONS, 0); 62 | } 63 | 64 | 65 | void CAppAlreadyRuningDlg::OnBnClickedShowHideMainWindowButton() 66 | { 67 | ::PostMessage(m_handle, WM_COMMAND, ID_SHOW_MAIN_WND, 0); 68 | } 69 | 70 | 71 | void CAppAlreadyRuningDlg::OnBnClickedShowHideTaskbarWindowButton() 72 | { 73 | ::PostMessage(m_handle, WM_COMMAND, ID_SHOW_TASK_BAR_WND, 0); 74 | } 75 | -------------------------------------------------------------------------------- /TrafficMonitor/SupportedRenderEnums.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SupportedRenderEnums.h" 3 | #include "TaskBarDlgDrawCommon.h" 4 | 5 | CSupportedRenderEnums::CSupportedRenderEnums() 6 | { 7 | if (CDCompositionSupport::CheckSupport() && CDxgi1Support2::CheckSupport()) 8 | { 9 | m_enums[D2D1_WITH_DCOMPOSITION_INDEX] = true; 10 | } 11 | if (CTaskBarDlgDrawCommonSupport::CheckSupport()) 12 | { 13 | m_enums[D2D1_INDEX] = true; 14 | } 15 | } 16 | 17 | void CSupportedRenderEnums::EnableDefaultOnly() noexcept 18 | { 19 | m_enums = decltype(m_enums){1}; 20 | } 21 | 22 | void CSupportedRenderEnums::DisableD2D1() noexcept 23 | { 24 | m_enums[D2D1_INDEX] = false; 25 | } 26 | 27 | auto CSupportedRenderEnums::GetAutoFitEnum() const noexcept 28 | -> DrawCommonHelper::RenderType 29 | { 30 | std::size_t i; 31 | for (i = m_enums.size() - 1; i > 0; --i) 32 | { 33 | if (m_enums[i]) 34 | { 35 | break; 36 | } 37 | } 38 | switch (i) 39 | { 40 | case D2D1_INDEX: 41 | return DrawCommonHelper::RenderType::D2D1; 42 | case D2D1_WITH_DCOMPOSITION_INDEX: 43 | return DrawCommonHelper::RenderType::D2D1_WITH_DCOMPOSITION; 44 | case DEFAULT_INDEX: 45 | return DrawCommonHelper::RenderType::DEFAULT; 46 | default: 47 | return DrawCommonHelper::RenderType::DEFAULT; 48 | } 49 | } 50 | 51 | auto CSupportedRenderEnums::GetMaxSupportedRenderEnum() const noexcept 52 | -> DrawCommonHelper::RenderType 53 | { 54 | if (m_enums[D2D1_WITH_DCOMPOSITION_INDEX]) 55 | { 56 | return DrawCommonHelper::RenderType::D2D1_WITH_DCOMPOSITION; 57 | } 58 | else if (m_enums[D2D1_INDEX]) 59 | { 60 | return DrawCommonHelper::RenderType::D2D1; 61 | } 62 | else if (m_enums[DEFAULT_INDEX]) 63 | { 64 | return DrawCommonHelper::RenderType::DEFAULT; 65 | } 66 | return DrawCommonHelper::RenderType::DEFAULT; 67 | } 68 | 69 | bool CSupportedRenderEnums::IsD2D1WithDCompositionEnabled() const noexcept 70 | { 71 | return m_enums[D2D1_WITH_DCOMPOSITION_INDEX]; 72 | } 73 | 74 | bool CSupportedRenderEnums::IsD2D1Enabled() const noexcept 75 | { 76 | return m_enums[D2D1_INDEX]; 77 | } -------------------------------------------------------------------------------- /TrafficMonitor/TaskbarItemOrderHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | 4 | //显示的项目 5 | enum DisplayItem 6 | { 7 | TDI_UP = 1 << 0, 8 | TDI_DOWN = 1 << 1, 9 | TDI_CPU = 1 << 2, 10 | TDI_MEMORY = 1 << 3, 11 | TDI_GPU_USAGE = 1 << 4, 12 | TDI_CPU_TEMP = 1 << 5, 13 | TDI_GPU_TEMP = 1 << 6, 14 | TDI_HDD_TEMP = 1 << 7, 15 | TDI_MAIN_BOARD_TEMP = 1 << 8, 16 | TDI_HDD_USAGE = 1 << 9, 17 | TDI_TOTAL_SPEED = 1 << 10, 18 | TDI_CPU_FREQ = 1 << 11 19 | }; 20 | 21 | //显示的项目 22 | struct CommonDisplayItem 23 | { 24 | bool is_plugin{}; //是否为插件项目 25 | DisplayItem item_type{}; //内建的显示项目 26 | IPluginItem* plugin_item{}; //插件显示项目 27 | 28 | CommonDisplayItem() {} 29 | CommonDisplayItem(DisplayItem item); 30 | CommonDisplayItem(IPluginItem* item); 31 | 32 | bool operator<(const CommonDisplayItem&) const; 33 | bool operator==(const CommonDisplayItem&) const; 34 | 35 | CString GetItemName() const; 36 | }; 37 | 38 | //所有显示项目的集合 39 | const std::set AllDisplayItems 40 | { 41 | TDI_UP, TDI_DOWN, TDI_CPU, TDI_MEMORY 42 | #ifndef WITHOUT_TEMPERATURE 43 | , TDI_GPU_USAGE, TDI_CPU_TEMP, TDI_GPU_TEMP, TDI_HDD_TEMP, TDI_MAIN_BOARD_TEMP, TDI_HDD_USAGE,TDI_CPU_FREQ 44 | #endif 45 | , TDI_TOTAL_SPEED 46 | }; 47 | 48 | 49 | class CTaskbarItemOrderHelper 50 | { 51 | public: 52 | CTaskbarItemOrderHelper(bool displayed_only = false); 53 | 54 | void Init(); 55 | 56 | //根据设定的顺序获取任务窗口每个显示项目 57 | std::vector GetAllDisplayItemsWithOrder() const; 58 | 59 | void FromString(const std::wstring& str); 60 | std::wstring ToString() const; 61 | void SetOrder(const vector& item_order); 62 | const vector& GetItemOrderConst() const; 63 | vector& GetItemOrder(); 64 | 65 | static CString GetItemDisplayName(CommonDisplayItem item); 66 | static bool IsItemDisplayed(CommonDisplayItem item); 67 | 68 | private: 69 | //规范m_item_order里的项目,如果m_item_order里有序号超过了显示项目的个数,则将其移除,并在后面添加缺少的项目的序号 70 | void NormalizeItemOrder(); 71 | 72 | private: 73 | vector m_item_order; //保存每个项目的顺序 74 | vector m_all_item_in_default_order; //以默认顺序保存的所有显示项目 75 | bool m_displayed_only; 76 | }; 77 | -------------------------------------------------------------------------------- /TrafficMonitor/NetworkInfoDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include"Common.h" 3 | #include "afxcmn.h" 4 | #include "AdapterCommon.h" 5 | #include "BaseDialog.h" 6 | #include "ListCtrlEx.h" 7 | 8 | // CNetworkInfoDlg 对话框 9 | 10 | class CNetworkInfoDlg : public CBaseDialog 11 | { 12 | DECLARE_DYNAMIC(CNetworkInfoDlg) 13 | 14 | public: 15 | CNetworkInfoDlg(vector& adapters, MIB_IFROW* pIfRow, int connection_selected, CWnd* pParent = NULL); // 标准构造函数 16 | virtual ~CNetworkInfoDlg(); 17 | 18 | // 对话框数据 19 | #ifdef AFX_DESIGN_TIME 20 | enum { IDD = IDD_NETWORK_INFO_DIALOG }; 21 | #endif 22 | 23 | SYSTEMTIME m_start_time; //程序启动的时间 24 | 25 | protected: 26 | 27 | vector& m_connections; 28 | MIB_IFROW* m_pIfRow; 29 | int m_connection_selected; //当前对话框显示的连接 30 | int m_current_connection; //初始选择的连接 31 | 32 | CListCtrlEx m_info_list; 33 | CMenu m_menu; 34 | CString m_selected_string; 35 | CFont m_font_bold; //默认字体的粗体 36 | 37 | CWinThread* m_pGetIPThread; //获取外网IP的线程 38 | bool m_ip_acquired{ false }; //如果已获取外网ip地址,则为true 39 | 40 | //void GetIPAddress(); //获取IP地址 41 | void ShowInfo(); 42 | void GetProgramElapsedTime(); 43 | MIB_IFROW& GetConnectIfTable(int connection_index); //获取当前选择的网络连接的MIB_IFROW对象。connection_index为m_connections中的索引 44 | NetWorkConection GetConnection(int connection_index); //获取当前选择的网络连接的NetWorkConection对象。connection_index为m_connections中的索引 45 | 46 | //获取外网IP的线程函数 47 | static UINT GetInternetIPThreadFunc(LPVOID lpParam); 48 | 49 | virtual CString GetDialogName() const override; 50 | 51 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 52 | 53 | DECLARE_MESSAGE_MAP() 54 | 55 | virtual BOOL OnInitDialog(); 56 | public: 57 | afx_msg void OnCopyText(); 58 | afx_msg void OnNMRClickInfoList1(NMHDR* pNMHDR, LRESULT* pResult); 59 | afx_msg void OnClose(); 60 | afx_msg void OnBnClickedPreviousButton(); 61 | afx_msg void OnBnClickedNextButton(); 62 | virtual BOOL PreTranslateMessage(MSG* pMsg); 63 | afx_msg void OnTimer(UINT_PTR nIDEvent); 64 | afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); 65 | afx_msg void OnNMDblclkInfoList1(NMHDR* pNMHDR, LRESULT* pResult); 66 | }; 67 | -------------------------------------------------------------------------------- /version_utf8.info: -------------------------------------------------------------------------------- 1 | 1.84.1 2 | 3 | https://github.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x86.zip 4 | https://github.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x64.zip 5 | https://github.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x86_Lite.zip 6 | https://github.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x64_Lite.zip 7 | 8 | 9 | https://gitee.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x86.zip 10 | https://gitee.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x64.zip 11 | https://gitee.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x86_Lite.zip 12 | https://gitee.com/zhongyang219/TrafficMonitor/releases/download/V1.84.1/TrafficMonitor_V1.84.1_x64_Lite.zip 13 | 14 | 15 | 修正Windows11下任务栏窗口无法显示到左边的问题\n修正任务栏显示在桌面两侧时任务栏窗口会显示不全的问题\n修正Windows11 22H2中,关闭了所有窗口且任务栏上没有固定任何图标时,任务栏窗口位置不正确的问题\n为触屏设备添加长按右键菜单的支持\n修正由于最新版本Windows11中搜索按钮比较宽导致任务栏窗口的位置不正确的问题\n修正“关于”对话框的大小有时不正确的问题 16 | Fixed the issue that the taskbar window cannot be displayed on the left side in Window 11.\nFixed the issue that the information in the taskbar window could not be fully displayed when the taskbar on the left or right side of the desktop.\nFixed the issue in Windows 11 22H2, when all the windows are closed and no icons are fixed on the taskbar, the position of the taskbar window is not correct.\nAdded the support of long press to show context menu in touchscreen devices.\nFixed the issue that the position of the taskbar window is not correct due to the wide search button in the latest version of Windows 11.\nFixed the issue that the size of "About" dialog box is not correct. 17 | 修正Windows11下工作列視窗無法顯示到左邊的問題\n修正工作列顯示在桌面兩側時工作列視窗會顯示不全的問題\n修正Windows11 22H2中,關閉了所有視窗且工作列上沒有固定任何圖示時,工作列視窗位置不正確的問題\n為觸屏裝置新增長按右鍵選單的支援\n修正由於最新版本Windows11中搜索按鈕比較寬導致工作列視窗的位置不正確的問題\n修正“關於”對話方塊的大小有時不正確的問題 18 | -------------------------------------------------------------------------------- /TrafficMonitor/PluginManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PluginInterface.h" 3 | #include 4 | #include "TaskbarItemOrderHelper.h" 5 | #include 6 | 7 | typedef ITMPlugin* (*pfTMPluginGetInstance)(); 8 | 9 | //用于加载和管理插件 10 | class CPluginManager 11 | { 12 | public: 13 | //插件的状态 14 | enum class PluginState 15 | { 16 | PS_SUCCEED, //载入成功 17 | PS_MUDULE_LOAD_FAILED, //dll加载失败 18 | PS_FUNCTION_GET_FAILED, //插件函数获取失败 19 | PS_VERSION_NOT_SUPPORT, //插件版本不被支持 20 | PS_DISABLE //已禁用 21 | }; 22 | 23 | //插件信息 24 | struct PluginInfo 25 | { 26 | wstring file_path; //文件路径 27 | HMODULE plugin_module{}; //dll module 28 | ITMPlugin* plugin{}; //插件对象 29 | std::vector plugin_items; //插件提供的所有显示项目 30 | PluginState state{}; //插件的状态 31 | DWORD error_code{}; //错误代码(GetLastError的返回值) 32 | std::map properties; //插件属性 33 | std::wstring Property(ITMPlugin::PluginInfoIndex) const; 34 | }; 35 | 36 | CPluginManager(); 37 | ~CPluginManager(); 38 | void LoadPlugins(); 39 | 40 | const std::vector& GetPluginItems() const; 41 | const std::vector& GetPlugins() const; 42 | IPluginItem* GetItemById(const std::wstring& item_id); 43 | IPluginItem* GetItemByIndex(int index); 44 | int GetItemIndex(IPluginItem* item) const; 45 | ITMPlugin* GetPluginByItem(IPluginItem* pItem); 46 | int GetPluginIndex(ITMPlugin* plugin) const; 47 | 48 | //遍历所有插件 49 | //func: 参数为遍历到的ITMPlugin对象 50 | void EnumPlugin(std::function func) const; 51 | 52 | //遍历所有插件项目 53 | //func: 参数为遍历到的IPluginItem对象 54 | void EnumPluginItem(std::function func) const; 55 | 56 | const std::set& AllDisplayItemsWithPlugins(); 57 | 58 | int GetItemWidth(IPluginItem* pItem, CDC* pDC); 59 | 60 | private: 61 | static void ReplacePluginDrawTextFunction(HMODULE plgin_dll_module) noexcept; 62 | static void ReplaceMfcDrawTextFunction() noexcept; 63 | 64 | private: 65 | std::vector m_plugins; 66 | std::vector m_modules; 67 | std::set m_all_display_items_with_plugins; //包含插件在内的所有任务栏显示项目 68 | std::map m_plguin_item_map; //用于根据插件项目查找对应插件的map 69 | }; 70 | -------------------------------------------------------------------------------- /TrafficMonitor/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | MICROSOFT 基础类库 : TrafficMonitor 项目概述 3 | =============================================================================== 4 | 5 | 应用程序向导已为您创建了此 TrafficMonitor 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 6 | 7 | 本文件概要介绍组成 TrafficMonitor 应用程序的每个文件的内容。 8 | 9 | TrafficMonitor.vcxproj 10 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 11 | 12 | TrafficMonitor.vcxproj.filters 13 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 14 | 15 | TrafficMonitor.h 16 | 这是应用程序的主头文件。 17 | 其中包括其他项目特定的标头(包括 Resource.h),并声明 CTrafficMonitorApp 应用程序类。 18 | 19 | TrafficMonitor.cpp 20 | 这是包含应用程序类 CTrafficMonitorApp 的主应用程序源文件。 21 | 22 | TrafficMonitor.rc 23 | 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 24 | 25 | res\TrafficMonitor.ico 26 | 这是用作应用程序图标的图标文件。此图标包括在主资源文件 TrafficMonitor.rc 中。 27 | 28 | res\TrafficMonitor.rc2 29 | 此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 30 | 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | 34 | 应用程序向导创建一个对话框类: 35 | 36 | TrafficMonitorDlg.h、TrafficMonitorDlg.cpp - 对话框 37 | 这些文件包含 CTrafficMonitorDlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 TrafficMonitor.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。 38 | 39 | ///////////////////////////////////////////////////////////////////////////// 40 | 41 | 其他功能: 42 | 43 | ActiveX 控件 44 | 该应用程序包含对使用 ActiveX 控件的支持。 45 | 46 | ///////////////////////////////////////////////////////////////////////////// 47 | 48 | 其他标准文件: 49 | 50 | StdAfx.h, StdAfx.cpp 51 | 这些文件用于生成名为 TrafficMonitor.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 52 | 53 | Resource.h 54 | 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 55 | 56 | TrafficMonitor.manifest 57 | Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 58 | ///////////////////////////////////////////////////////////////////////////// 59 | 60 | 其他注释: 61 | 62 | 应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 63 | 64 | 如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 65 | 有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 66 | 67 | ///////////////////////////////////////////////////////////////////////////// 68 | -------------------------------------------------------------------------------- /TrafficMonitor/Dxgi1Support2.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Dxgi1Support2.h" 3 | #include "Common.h" 4 | #include "DllFunctions.h" 5 | 6 | void CDxgiSwapChain1::Recreate(Microsoft::WRL::ComPtr p_device, const DXGI_SWAP_CHAIN_DESC1& ref_desc1, IDXGIOutput* p_output) 7 | { 8 | CallFunctionForEachResource(m_resource_tracker); 9 | 10 | ThrowIfFailed( 11 | CDxgi1Support2::GetFactory()->CreateSwapChainForComposition( 12 | p_device.Get(), 13 | &ref_desc1, 14 | p_output, 15 | &m_p_swap_chain1), 16 | TRAFFICMONITOR_ERROR_STR("Create swap chain for composition failed.")); 17 | 18 | CallFunctionForEachResource(m_resource_tracker, m_p_swap_chain1); 19 | } 20 | 21 | auto CDxgiSwapChain1::GetStorage() 22 | -> std::shared_ptr 23 | { 24 | return m_resource_tracker.GetSharedResourceTrackerStorage(); 25 | } 26 | 27 | void CDxgiSwapChain1::Resize(std::uint32_t width, std::uint32_t height) 28 | { 29 | CallFunctionForEachResource(m_resource_tracker); 30 | 31 | ThrowIfFailed( 32 | m_p_swap_chain1->ResizeBuffers( 33 | 0, 34 | width, 35 | height, 36 | DXGI_FORMAT_R8G8B8A8_UNORM, 37 | 0), 38 | TRAFFICMONITOR_ERROR_STR("Resize swap chain failed.")); 39 | 40 | CallFunctionForEachResource(m_resource_tracker, m_p_swap_chain1); 41 | } 42 | 43 | bool CDxgi1Support2::CheckSupport() 44 | { 45 | const static auto result = 46 | FunctionChecker::CheckFunctionExist(_T("dxgi.dll"), "CreateDXGIFactory2"); 47 | return result; 48 | } 49 | 50 | IDXGIFactory2* CDxgi1Support2::GetFactory() 51 | { 52 | static auto result = MakeStaticVariableWrapper( 53 | [](auto pp_factory) 54 | { 55 | *pp_factory = nullptr; 56 | auto flags = 0; 57 | #ifdef DEBUG 58 | flags |= DXGI_CREATE_FACTORY_DEBUG; 59 | #endif 60 | ThrowIfFailed( 61 | CDllFunctions::CreateDXGIFactory2( 62 | flags, 63 | IID_PPV_ARGS(pp_factory)), 64 | TRAFFICMONITOR_ERROR_STR("Create dxgi factory2 failed.")); 65 | }, 66 | [](auto pp_factory) 67 | { RELEASE_COM(*pp_factory); }); 68 | 69 | return result.Get(); 70 | } 71 | -------------------------------------------------------------------------------- /TrafficMonitor/IDrawCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CommonData.h" 3 | 4 | class IDrawBuffer 5 | { 6 | public: 7 | virtual ~IDrawBuffer() = default; 8 | }; 9 | 10 | class IDrawCommon 11 | { 12 | public: 13 | // 拉伸模式 14 | enum class StretchMode 15 | { 16 | STRETCH, // 拉伸,会改变比例 17 | FILL, // 填充,不改变比例,会裁剪长边 18 | FIT // 适应,不会改变比例,不裁剪 19 | }; 20 | 21 | virtual void SetBackColor(COLORREF back_color, BYTE alpha = 255) = 0; 22 | // 设置绘制文本的字体 23 | virtual void SetFont(CFont* pfont) = 0; 24 | // 在指定的矩形区域内绘制文本 25 | virtual void DrawWindowText(CRect rect, LPCTSTR lpszString, COLORREF color, Alignment align = Alignment::LEFT, bool draw_back_ground = false, bool multi_line = false, BYTE alpha = 255) = 0; 26 | // 设置绘图剪辑区域 27 | virtual void SetDrawRect(CRect rect) = 0; 28 | // 用纯色填充矩形 29 | virtual void FillRect(CRect rect, COLORREF color, BYTE alpha = 255) = 0; 30 | // 绘制矩形边框。如果dot_line为true,则为虚线 31 | virtual void DrawRectOutLine(CRect rect, COLORREF color, int width = 1, bool dot_line = false, BYTE alpha = 255) = 0; 32 | // 使用当前画笔画线 33 | virtual void DrawLine(CPoint start_point, int height, COLORREF color, BYTE alpha = 255) = 0; 34 | virtual void SetTextColor(const COLORREF color, BYTE alpha = 255) = 0; 35 | // 绘制一个位图 36 | // (注意:当stretch_mode设置为StretchMode::FILL(填充)时,会设置绘图剪辑区域,如果之后需要绘制其他图形, 37 | // 需要重新设置绘图剪辑区域,否则图片外的区域会无法绘制) 38 | virtual void DrawBitmap(HBITMAP hbitmap, CPoint start_point, CSize size, StretchMode stretch_mode = StretchMode::STRETCH, BYTE alpha = 255) = 0; 39 | virtual ~IDrawCommon() = default; 40 | }; 41 | 42 | namespace DrawCommonHelper 43 | { 44 | /** 45 | * @brief 渲染器类型的枚举,新增渲染器类型时应当添加枚举到其中 46 | * 47 | */ 48 | enum class RenderType 49 | { 50 | // 使用GDI 51 | DEFAULT, 52 | // 如果支持,使用D2D1 53 | D2D1, 54 | // 如果系统大于win8.1,则在使用D2D1时利用DirectComposition呈现结果 55 | D2D1_WITH_DCOMPOSITION 56 | }; 57 | 58 | constexpr BYTE GDI_NO_MODIFIED_FLAG = 0x01; 59 | constexpr BYTE OPAQUE_ALPHA_VALUE = 0xFF; 60 | constexpr BYTE TRANSPARENT_ALPHA_VALUE = 0x00; 61 | constexpr BYTE AVAILABLE_MINIMUM_ALPHA = 0x02; 62 | constexpr BYTE GDI_MODIFIED_FLAG = 0x00; 63 | } 64 | 65 | template 66 | struct variant_storage 67 | { 68 | ~variant_storage() = delete; 69 | }; 70 | template 71 | struct variant_storage 72 | { 73 | union 74 | { 75 | First m_head; 76 | variant_storage m_tail; 77 | }; 78 | ~variant_storage() = delete; 79 | }; 80 | -------------------------------------------------------------------------------- /TrafficMonitor/WinVersionHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "WinVersionHelper.h" 3 | #include "WindowsSettingHelper.h" 4 | 5 | 6 | CWinVersionHelper::CWinVersionHelper() 7 | { 8 | DWORD dwMajorVer{}, dwMinorVer{}, dwBuildNumber{}; 9 | HMODULE hModNtdll{}; 10 | if (hModNtdll = ::LoadLibraryW(L"ntdll.dll")) 11 | { 12 | typedef void (WINAPI *pfRTLGETNTVERSIONNUMBERS)(DWORD*, DWORD*, DWORD*); 13 | pfRTLGETNTVERSIONNUMBERS pfRtlGetNtVersionNumbers; 14 | pfRtlGetNtVersionNumbers = (pfRTLGETNTVERSIONNUMBERS)::GetProcAddress(hModNtdll, "RtlGetNtVersionNumbers"); 15 | if (pfRtlGetNtVersionNumbers) 16 | { 17 | pfRtlGetNtVersionNumbers(&dwMajorVer, &dwMinorVer, &dwBuildNumber); 18 | dwBuildNumber &= 0x0ffff; 19 | } 20 | ::FreeLibrary(hModNtdll); 21 | hModNtdll = NULL; 22 | } 23 | m_major_version = dwMajorVer; 24 | m_minor_version = dwMinorVer; 25 | m_build_number = dwBuildNumber; 26 | 27 | CWindowsSettingHelper::CheckWindows10LightTheme(); 28 | } 29 | 30 | 31 | CWinVersionHelper::~CWinVersionHelper() 32 | { 33 | } 34 | 35 | bool CWinVersionHelper::IsWindows11OrLater() const 36 | { 37 | if (m_major_version > 10) 38 | return true; 39 | else if (m_major_version == 10 && m_minor_version > 0) 40 | return true; 41 | else if (m_major_version == 10 && m_minor_version == 0 && m_build_number >= 21996) 42 | return true; 43 | else return false; 44 | } 45 | 46 | bool CWinVersionHelper::IsWindows10FallCreatorOrLater() const 47 | { 48 | if (m_major_version > 10) 49 | return true; 50 | else if (m_major_version == 10 && m_minor_version > 0) 51 | return true; 52 | else if (m_major_version == 10 && m_minor_version == 0 && m_build_number >= 16299) 53 | return true; 54 | else return false; 55 | } 56 | 57 | bool CWinVersionHelper::IsWindows7() const 58 | { 59 | return (m_major_version == 6 && m_minor_version == 1); 60 | } 61 | 62 | bool CWinVersionHelper::IsWindows8Or8point1() const 63 | { 64 | return (m_major_version == 6 && m_minor_version > 1); 65 | } 66 | 67 | bool CWinVersionHelper::IsWindows8Point1OrLater() const 68 | { 69 | if (m_major_version > 6) 70 | { 71 | return true; 72 | } 73 | else if (m_major_version == 6 && m_minor_version >= 3) 74 | { 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | bool CWinVersionHelper::IsWindows8OrLater() const 81 | { 82 | if (m_major_version > 6) 83 | return true; 84 | else if (m_major_version == 6 && m_minor_version >= 2) 85 | return true; 86 | else return false; 87 | } 88 | 89 | bool CWinVersionHelper::IsWindows10OrLater() const 90 | { 91 | return m_major_version >= 10; 92 | } 93 | -------------------------------------------------------------------------------- /TrafficMonitor/DonateDlg.cpp: -------------------------------------------------------------------------------- 1 | // DonateDlg.cpp : 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "DonateDlg.h" 7 | #include "afxdialogex.h" 8 | #include "DrawCommon.h" 9 | 10 | 11 | // CDonateDlg 对话框 12 | 13 | IMPLEMENT_DYNAMIC(CDonateDlg, CBaseDialog) 14 | 15 | CDonateDlg::CDonateDlg(CWnd* pParent /*=NULL*/) 16 | : CBaseDialog(IDD_DONATE_DIALOG, pParent) 17 | { 18 | 19 | } 20 | 21 | CDonateDlg::~CDonateDlg() 22 | { 23 | } 24 | 25 | void CDonateDlg::DoDataExchange(CDataExchange* pDX) 26 | { 27 | CBaseDialog::DoDataExchange(pDX); 28 | //DDX_Control(pDX, IDC_DONATE_PIC, m_donate_pic); 29 | } 30 | 31 | 32 | CString CDonateDlg::GetDialogName() const 33 | { 34 | return _T("DonateDlg"); 35 | } 36 | 37 | BEGIN_MESSAGE_MAP(CDonateDlg, CBaseDialog) 38 | ON_WM_PAINT() 39 | END_MESSAGE_MAP() 40 | 41 | 42 | // CDonateDlg 消息处理程序 43 | 44 | 45 | BOOL CDonateDlg::OnInitDialog() 46 | { 47 | CBaseDialog::OnInitDialog(); 48 | 49 | // TODO: 在此添加额外的初始化 50 | SetWindowText(CCommon::LoadText(IDS_TITLE_DONATE)); 51 | 52 | //计算两个二维码图片的位置 53 | CRect rect{}; 54 | CWnd* pWnd = nullptr; 55 | pWnd = GetDlgItem(IDC_TEXT_STATIC); 56 | if (pWnd != nullptr) 57 | { 58 | pWnd->GetWindowRect(rect); 59 | ScreenToClient(rect); 60 | } 61 | 62 | CRect rc_pic_area; 63 | GetClientRect(rc_pic_area); 64 | rc_pic_area.top = rect.bottom + theApp.DPI(8); 65 | rc_pic_area.left += theApp.DPI(10); 66 | rc_pic_area.right -= theApp.DPI(10); 67 | pWnd = GetDlgItem(IDOK); 68 | if (pWnd != nullptr) 69 | { 70 | pWnd->GetWindowRect(rect); 71 | ScreenToClient(rect); 72 | } 73 | rc_pic_area.bottom = rect.top - theApp.DPI(8); 74 | m_pic1_rect = rc_pic_area; 75 | m_pic1_rect.right = m_pic1_rect.left + (rc_pic_area.Width() / 2) - theApp.DPI(4); 76 | 77 | m_pic2_rect = rc_pic_area; 78 | m_pic2_rect.left = m_pic2_rect.right - (rc_pic_area.Width() / 2) + theApp.DPI(4); 79 | 80 | return TRUE; // return TRUE unless you set the focus to a control 81 | // 异常: OCX 属性页应返回 FALSE 82 | } 83 | 84 | 85 | void CDonateDlg::OnPaint() 86 | { 87 | CPaintDC dc(this); // device context for painting 88 | // TODO: 在此处添加消息处理程序代码 89 | // 不为绘图消息调用 CBaseDialog::OnPaint() 90 | CDrawCommon draw; 91 | draw.Create(&dc, this); 92 | draw.DrawBitmap(IDB_DONATE_BITMAP, m_pic1_rect.TopLeft(), m_pic1_rect.Size(), CDrawCommon::StretchMode::FIT); 93 | draw.DrawBitmap(IDB_DONATE_WECHAT, m_pic2_rect.TopLeft(), m_pic2_rect.Size(), CDrawCommon::StretchMode::FIT); 94 | } 95 | -------------------------------------------------------------------------------- /TrafficMonitor/DrawTextManager.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DrawTextManager.h" 3 | #include 4 | 5 | EnableWriteMemoryGuard::~EnableWriteMemoryGuard() 6 | { 7 | m_state = ::VirtualProtect(m_p_memory, m_memory_size, m_last_flag, &m_last_flag); 8 | } 9 | 10 | bool EnableWriteMemoryGuard::GetState() 11 | { 12 | return m_state; 13 | } 14 | 15 | int WINAPI User32DrawTextManager::A::CustomDrawTextA(HDC hdc, LPCSTR lpchText, int cchText, LPRECT lprc, UINT format) 16 | { 17 | if (BaseSettings::GetEnable()) 18 | { 19 | return BaseSettings::m_replaced_function(hdc, lpchText, cchText, lprc, format); 20 | } 21 | else 22 | { 23 | return (BaseSettings::GetOriginalFunction())(hdc, lpchText, cchText, lprc, format); 24 | } 25 | } 26 | 27 | auto User32DrawTextManager::A::GetFunction() noexcept 28 | -> Function 29 | { 30 | return &CustomDrawTextA; 31 | } 32 | 33 | int WINAPI User32DrawTextManager::W::CustomDrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format) 34 | { 35 | if (BaseSettings::GetEnable()) 36 | { 37 | return BaseSettings::m_replaced_function(hdc, lpchText, cchText, lprc, format); 38 | } 39 | else 40 | { 41 | return (BaseSettings::GetOriginalFunction())(hdc, lpchText, cchText, lprc, format); 42 | } 43 | } 44 | 45 | auto User32DrawTextManager::W::GetFunction() noexcept 46 | -> Function 47 | { 48 | return &CustomDrawTextW; 49 | } 50 | 51 | int WINAPI User32DrawTextManager::ExA::CustomDrawTextExA(HDC hdc, LPSTR lpchText, int cchText, LPRECT lprc, UINT format, LPDRAWTEXTPARAMS lpdtp) 52 | { 53 | if (BaseSettings::GetEnable()) 54 | { 55 | return BaseSettings::m_replaced_function(hdc, lpchText, cchText, lprc, format, lpdtp); 56 | } 57 | else 58 | { 59 | return (BaseSettings::GetOriginalFunction())(hdc, lpchText, cchText, lprc, format, lpdtp); 60 | } 61 | } 62 | 63 | auto User32DrawTextManager::ExA::GetFunction() noexcept 64 | -> Function 65 | { 66 | return &CustomDrawTextExA; 67 | } 68 | 69 | int WINAPI User32DrawTextManager::ExW::CustomDrawTextExW(HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc, UINT format, LPDRAWTEXTPARAMS lpdtp) 70 | { 71 | if (BaseSettings::GetEnable()) 72 | { 73 | return BaseSettings::m_replaced_function(hdc, lpchText, cchText, lprc, format, lpdtp); 74 | } 75 | else 76 | { 77 | return (BaseSettings::GetOriginalFunction())(hdc, lpchText, cchText, lprc, format, lpdtp); 78 | } 79 | } 80 | 81 | auto User32DrawTextManager::ExW::GetFunction() noexcept 82 | -> Function 83 | { 84 | return &CustomDrawTextExW; 85 | } 86 | -------------------------------------------------------------------------------- /TrafficMonitor/DrawCommonFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | #include 4 | #include "IDrawCommon.h" 5 | #include "DrawCommon.h" 6 | #include "TaskBarDlgDrawCommon.h" 7 | 8 | template 9 | struct StackObjectDeleter 10 | { 11 | using pointer = std::add_pointer_t; 12 | void operator()(pointer p_stack_object) const noexcept 13 | { 14 | if (p_stack_object) 15 | { 16 | Destroy(p_stack_object); 17 | } 18 | } 19 | }; 20 | using UniqueIDrawCommon = std::unique_ptr>; 21 | using UniqueIDrawBuffer = std::unique_ptr>; 22 | 23 | /** 24 | * @brief 新增渲染器类型后,将新类型写到下面类型的模板参数中 25 | * 26 | */ 27 | using DrawCommonUnionStorage = variant_storage; 28 | /** 29 | * @brief 新增缓冲器(即析构时提交窗口绘制内容到系统的对象)类型后,将新类型写入到下面类型的模板参数中 30 | * 31 | */ 32 | using DrawBufferUnionStorage = variant_storage; 33 | struct InvolvedDrawCommonStorages 34 | { 35 | DrawBufferUnionStorage m_draw_buffer_union_storage; 36 | DrawCommonUnionStorage m_draw_common_union_storage; 37 | ~InvolvedDrawCommonStorages() = delete; 38 | }; 39 | /** 40 | * @brief 具有DrawCommon和DrawBuffer栈内存以及它们对应独占指针的栈内存块, 41 | 注意:它会先析构DrawCommon再析构DrawBuffer 42 | * 43 | */ 44 | struct AllInvolvedDrawCommonObjectsStorage 45 | { 46 | std_aligned_storage m_storage{}; 47 | // 先析构DrawCommon再析构DrawBuffer 48 | UniqueIDrawBuffer m_unique_draw_buffer{}; 49 | UniqueIDrawCommon m_unique_draw_common{}; 50 | // 禁用复制移动 51 | AllInvolvedDrawCommonObjectsStorage(const AllInvolvedDrawCommonObjectsStorage&) = delete; 52 | AllInvolvedDrawCommonObjectsStorage& operator=(const AllInvolvedDrawCommonObjectsStorage&) = delete; 53 | }; 54 | using AllInvolvedDrawCommonObjectsInitializer = std::function; 55 | using TaggedAllInvolvedDrawCommonObjectsInitializer = 56 | std::pair; 57 | 58 | /** 59 | * @brief 从栈内存中使用对应RenderType的函数初始化渲染器和缓冲器 60 | * 61 | * @param ref_object_storage 栈内存对象,其中包含具有该内存独占所有权的指针 62 | * @param render_type 渲染器类型枚举 63 | * @param initializer_list 渲染器类型枚举和对应的初始化函数的总的集合 64 | * @return std::tuple 不具有所有权的裸指针 65 | */ 66 | auto GetInterfaceFromAllInvolvedDrawCommonObjects( 67 | AllInvolvedDrawCommonObjectsStorage& ref_object_storage, 68 | DrawCommonHelper::RenderType render_type, 69 | std::initializer_list initializer_list) 70 | -> std::tuple; 71 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) <2019> 2 | 3 | "Anti 996" License Version 1.0 (Draft) 4 | 5 | Permission is hereby granted to any individual or legal entity 6 | obtaining a copy of this licensed work (including the source code, 7 | documentation and/or related items, hereinafter collectively referred 8 | to as the "licensed work"), free of charge, to deal with the licensed 9 | work for any purpose, including without limitation, the rights to use, 10 | reproduce, modify, prepare derivative works of, distribute, publish 11 | and sublicense the licensed work, subject to the following conditions: 12 | 13 | 1. The individual or the legal entity must conspicuously display, 14 | without modification, this License and the notice on each redistributed 15 | or derivative copy of the Licensed Work. 16 | 17 | 2. The individual or the legal entity must strictly comply with all 18 | applicable laws, regulations, rules and standards of the jurisdiction 19 | relating to labor and employment where the individual is physically 20 | located or where the individual was born or naturalized; or where the 21 | legal entity is registered or is operating (whichever is stricter). In 22 | case that the jurisdiction has no such laws, regulations, rules and 23 | standards or its laws, regulations, rules and standards are 24 | unenforceable, the individual or the legal entity are required to 25 | comply with Core International Labor Standards. 26 | 27 | 3. The individual or the legal entity shall not induce, suggest or force 28 | its employee(s), whether full-time or part-time, or its independent 29 | contractor(s), in any methods, to agree in oral or written form, to 30 | directly or indirectly restrict, weaken or relinquish his or her 31 | rights or remedies under such laws, regulations, rules and standards 32 | relating to labor and employment as mentioned above, no matter whether 33 | such written or oral agreements are enforceable under the laws of the 34 | said jurisdiction, nor shall such individual or the legal entity 35 | limit, in any methods, the rights of its employee(s) or independent 36 | contractor(s) from reporting or complaining to the copyright holder or 37 | relevant authorities monitoring the compliance of the license about 38 | its violation(s) of the said license. 39 | 40 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 41 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 42 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, 44 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 45 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE 46 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. 47 | -------------------------------------------------------------------------------- /PluginDemo/PluginDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 50 | 51 | 源文件 52 | 53 | 54 | 源文件 55 | 56 | 57 | 源文件 58 | 59 | 60 | 源文件 61 | 62 | 63 | 源文件 64 | 65 | 66 | 源文件 67 | 68 | 69 | 源文件 70 | 71 | 72 | 73 | 74 | 资源文件 75 | 76 | 77 | -------------------------------------------------------------------------------- /TrafficMonitor/SelectConnectionsDlg.cpp: -------------------------------------------------------------------------------- 1 | // SelectConnectionsDlg.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "SelectConnectionsDlg.h" 7 | #include "afxdialogex.h" 8 | #include "AdapterCommon.h" 9 | 10 | // CSelectConnectionsDlg 对话框 11 | 12 | IMPLEMENT_DYNAMIC(CSelectConnectionsDlg, CBaseDialog) 13 | 14 | CSelectConnectionsDlg::CSelectConnectionsDlg(const StringSet& connections_hide, CWnd* pParent /*=nullptr*/) 15 | : m_connections_hide(connections_hide), CBaseDialog(IDD_SELECT_CONNECTIONS_DIALOG, pParent) 16 | { 17 | std::vector connections; 18 | CAdapterCommon::GetAdapterInfo(connections); 19 | for (const auto& item : connections) 20 | m_all_connection_names.push_back(CCommon::StrToUnicode(item.description.c_str())); 21 | } 22 | 23 | CSelectConnectionsDlg::~CSelectConnectionsDlg() 24 | { 25 | } 26 | 27 | void CSelectConnectionsDlg::DoDataExchange(CDataExchange* pDX) 28 | { 29 | CBaseDialog::DoDataExchange(pDX); 30 | DDX_Control(pDX, IDC_LIST1, m_list_ctrl); 31 | } 32 | 33 | 34 | CString CSelectConnectionsDlg::GetDialogName() const 35 | { 36 | //throw std::logic_error("The method or operation is not implemented."); 37 | return _T("SelectConnectionsDlg"); 38 | } 39 | 40 | BEGIN_MESSAGE_MAP(CSelectConnectionsDlg, CBaseDialog) 41 | END_MESSAGE_MAP() 42 | 43 | 44 | // CSelectConnectionsDlg 消息处理程序 45 | 46 | 47 | BOOL CSelectConnectionsDlg::OnInitDialog() 48 | { 49 | CBaseDialog::OnInitDialog(); 50 | 51 | // TODO: 在此添加额外的初始化 52 | SetIcon(theApp.GetMenuIcon(IDI_CONNECTION), FALSE); 53 | m_list_ctrl.SetItemHeight(0, theApp.DPI(20)); 54 | 55 | //向列表中添加项目 56 | for (const auto& connection_name : m_all_connection_names) 57 | { 58 | m_list_ctrl.AddString(connection_name.c_str()); 59 | if (!m_connections_hide.Contains(connection_name)) 60 | m_list_ctrl.SetCheck(m_list_ctrl.GetCount() - 1, TRUE); 61 | else 62 | m_list_ctrl.SetCheck(m_list_ctrl.GetCount() - 1, FALSE); 63 | } 64 | 65 | 66 | return TRUE; // return TRUE unless you set the focus to a control 67 | // 异常: OCX 属性页应返回 FALSE 68 | } 69 | 70 | 71 | void CSelectConnectionsDlg::OnOK() 72 | { 73 | // TODO: 在此添加专用代码和/或调用基类 74 | //保存每个项目的勾选状态 75 | bool is_empty{ true }; 76 | for (int i = 0; i < static_cast(m_all_connection_names.size()); i++) 77 | { 78 | bool is_checked = (m_list_ctrl.GetCheck(i) != 0); 79 | if (is_checked) 80 | is_empty = false; 81 | m_connections_hide.SetStrContained(m_all_connection_names[i], !is_checked); 82 | } 83 | 84 | if (is_empty) 85 | { 86 | MessageBox(CCommon::LoadText(IDS_SELECT_AT_LEASE_ONE_WARNING), NULL, MB_ICONWARNING | MB_OK); 87 | return; 88 | } 89 | 90 | CBaseDialog::OnOK(); 91 | } 92 | -------------------------------------------------------------------------------- /TrafficMonitor/MainWndSettingsDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ColorStatic.h" 3 | #include "afxwin.h" 4 | #include "SpinEdit.h" 5 | #include "TabDlg.h" 6 | #include "MainWndColorDlg.h" 7 | #include "ComboBox2.h" 8 | 9 | // CMainWndSettingsDlg 对话框 10 | 11 | class CMainWndSettingsDlg : public CTabDlg 12 | { 13 | DECLARE_DYNAMIC(CMainWndSettingsDlg) 14 | 15 | public: 16 | CMainWndSettingsDlg(CWnd* pParent = NULL); // 标准构造函数 17 | virtual ~CMainWndSettingsDlg(); 18 | 19 | //选项设置数据 20 | MainWndSettingData m_data; 21 | 22 | bool m_text_disable{ false }; //如果为true,则不允许设置“显示文本”,并不允许交换上传和下载的位置 23 | 24 | // 对话框数据 25 | #ifdef AFX_DESIGN_TIME 26 | enum { IDD = IDD_MAIN_WND_SETTINGS_DIALOG }; 27 | #endif 28 | 29 | 30 | protected: 31 | //控件变量 32 | CColorStatic m_color_static; 33 | CToolTipCtrl m_toolTip; 34 | CComboBox2 m_unit_combo; 35 | CButton m_hide_unit_chk; 36 | CSpinEdit m_font_size_edit; 37 | CComboBox2 m_double_click_combo; 38 | CComboBox2 m_memory_display_combo; 39 | 40 | protected: 41 | void DrawStaticColor(); 42 | void IniUnitCombo(); 43 | void EnableControl(); 44 | 45 | virtual void SetControlMouseWheelEnable(bool enable) override; 46 | 47 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 48 | 49 | DECLARE_MESSAGE_MAP() 50 | public: 51 | virtual BOOL OnInitDialog(); 52 | //afx_msg void OnEnChangeUploadEdit(); 53 | //afx_msg void OnEnChangeDownloadEdit(); 54 | //afx_msg void OnEnChangeCpuEdit(); 55 | //afx_msg void OnEnChangeMemoryEdit(); 56 | //afx_msg void OnBnClickedSetDefaultButton(); 57 | afx_msg void OnBnClickedSetFontButton(); 58 | afx_msg void OnBnClickedSwitchUpDownCheck(); 59 | afx_msg void OnBnClickedFullscreenHideCheck(); 60 | afx_msg void OnBnClickedSpeedShortModeCheck2(); 61 | afx_msg void OnCbnSelchangeUnitCombo(); 62 | afx_msg void OnBnClickedHideUnitCheck(); 63 | virtual BOOL PreTranslateMessage(MSG* pMsg); 64 | virtual void OnOK(); 65 | afx_msg void OnBnClickedHidePercentageCheck(); 66 | protected: 67 | afx_msg LRESULT OnStaticClicked(WPARAM wParam, LPARAM lParam); 68 | public: 69 | afx_msg void OnBnClickedSpecifyEachItemColorCheck(); 70 | afx_msg void OnCbnSelchangeDoubleClickCombo(); 71 | afx_msg void OnBnClickedSeparateValueUnitCheck(); 72 | afx_msg void OnBnClickedUnitByteRadio(); 73 | afx_msg void OnBnClickedUnitBitRadio(); 74 | afx_msg void OnBnClickedShowToolTipChk(); 75 | afx_msg void OnBnClickedBrowseButton(); 76 | afx_msg void OnBnClickedDisplayTextSettingButton(); 77 | afx_msg void OnCbnSelchangeMemoryDisplayCombo(); 78 | afx_msg void OnBnClickedAlwaysOnTopCheck(); 79 | afx_msg void OnBnClickedMousePenetrateCheck(); 80 | afx_msg void OnBnClickedLockWindowPosCheck(); 81 | afx_msg void OnBnClickedAlowOutOfBorderCheck(); 82 | }; 83 | -------------------------------------------------------------------------------- /PluginDemo/CustomDrawItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "CustomDrawItem.h" 3 | #include "DataManager.h" 4 | 5 | const wchar_t* CCustomDrawItem::GetItemName() const 6 | { 7 | return CDataManager::Instance().StringRes(IDS_CUSTOM_DRAW_ITEM); 8 | } 9 | 10 | const wchar_t* CCustomDrawItem::GetItemId() const 11 | { 12 | return L"b4zc373y"; 13 | } 14 | 15 | const wchar_t* CCustomDrawItem::GetItemLableText() const 16 | { 17 | return L""; 18 | } 19 | 20 | const wchar_t* CCustomDrawItem::GetItemValueText() const 21 | { 22 | return L""; 23 | } 24 | 25 | const wchar_t* CCustomDrawItem::GetItemValueSampleText() const 26 | { 27 | return L""; 28 | } 29 | 30 | bool CCustomDrawItem::IsCustomDraw() const 31 | { 32 | return true; 33 | } 34 | 35 | int CCustomDrawItem::GetItemWidth() const 36 | { 37 | return 50; 38 | } 39 | 40 | static void DrawLine(CDC* pDC, CPoint point1, CPoint point2, COLORREF color) 41 | { 42 | CPen aPen, * pOldPen; 43 | aPen.CreatePen(PS_SOLID, 1, color); 44 | pOldPen = pDC->SelectObject(&aPen); 45 | pDC->MoveTo(point1); 46 | pDC->LineTo(point2); 47 | pDC->SelectObject(pOldPen); 48 | } 49 | 50 | void CCustomDrawItem::DrawItem(void* hDC, int x, int y, int w, int h, bool dark_mode) 51 | { 52 | //绘图句柄 53 | CDC* pDC = CDC::FromHandle((HDC)hDC); 54 | //矩形区域 55 | CRect rect(CPoint(x, y), CSize(w, h)); 56 | //设置颜色 57 | COLORREF color1{ dark_mode ? RGB(255, 143, 107) : RGB(227, 81, 16) }; 58 | COLORREF color2{ dark_mode ? RGB(183, 241, 96) : RGB(83, 131, 11) }; 59 | COLORREF color3{ dark_mode ? RGB(158, 218, 251) : RGB(6, 111, 168) }; 60 | //显示时、分、秒的矩形区域 61 | CRect rect1{ rect }, rect2{ rect }, rect3{ rect }; 62 | rect1.bottom = rect.top + rect.Height() / 3; 63 | rect2 = rect1; 64 | rect2.MoveToY(rect1.bottom); 65 | rect3.top = rect2.bottom; 66 | rect1.DeflateRect(1, 1); 67 | rect2.DeflateRect(1, 1); 68 | rect3.DeflateRect(1, 1); 69 | //根据当前时间计算矩形的宽度 70 | SYSTEMTIME& time{ CDataManager::Instance().m_system_time }; 71 | int hour_width{ static_cast((time.wHour + time.wMinute / 60.0) * w / 24) }; 72 | int min_width{ static_cast((time.wMinute + time.wSecond / 60.0) * w / 60) }; 73 | int sec_width{ time.wSecond * w / 60 }; 74 | rect1.right = rect1.left + hour_width; 75 | rect2.right = rect2.left + min_width; 76 | rect3.right = rect3.left + sec_width; 77 | //填充矩形 78 | pDC->FillSolidRect(rect1, color1); 79 | pDC->FillSolidRect(rect2, color2); 80 | pDC->FillSolidRect(rect3, color3); 81 | //绘制刻度 82 | COLORREF color_scale{ dark_mode ? RGB(225, 225, 225) : RGB(45, 45, 45) }; 83 | for (int i{}; i < 24; i++) 84 | { 85 | int x_pos{ i * w / 24 + rect1.left }; 86 | DrawLine(pDC, CPoint(x_pos, rect1.top), CPoint(x_pos, i % 6 == 0 ? rect1.bottom : rect1.top + rect1.Height() / 2), color_scale); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /TrafficMonitor/HResultException.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "HResultException.h" 3 | #include "TrafficMonitor.h" 4 | 5 | namespace FunctionChecker 6 | { 7 | namespace Details 8 | { 9 | template 10 | bool StrategicCheck(LPCTSTR p_library_name, Strategy strategy) 11 | { 12 | bool result = false; 13 | auto hmodule = ::LoadLibrary(p_library_name); 14 | if (hmodule) 15 | { 16 | result = strategy(hmodule); 17 | ::FreeLibrary(hmodule); 18 | } 19 | return result; 20 | } 21 | } 22 | } // namespace FunctionChecker 23 | 24 | bool FunctionChecker::CheckLibraryExist(LPCTSTR p_library_name) noexcept 25 | { 26 | return Details::StrategicCheck(p_library_name, 27 | [](HMODULE) 28 | { return true; }); 29 | } 30 | 31 | bool FunctionChecker::CheckFunctionExist(LPCTSTR p_library_name, LPCSTR p_function_name) noexcept 32 | { 33 | return Details::StrategicCheck(p_library_name, 34 | [p_function_name](HMODULE h_library) -> bool 35 | { 36 | auto* p_test_function = ::GetProcAddress(h_library, p_function_name); 37 | return p_test_function != NULL; 38 | }); 39 | } 40 | 41 | const char* const ERROR_WHEN_CALL_COM_FUNCTION = "Error occurred when call COM function."; 42 | 43 | void ThrowIfFailed(HRESULT hr, const char* p_message) 44 | { 45 | ThrowIfFailed(hr, std::move(p_message)); 46 | } 47 | 48 | CHResultException::CHResultException(HRESULT hr, const char* p_message) 49 | : std::runtime_error{p_message}, m_hr{hr}, 50 | m_get_p_error_hr{::GetErrorInfo(0, &m_p_error)} 51 | { 52 | } 53 | 54 | auto CHResultException::GetError() 55 | -> Microsoft::WRL::ComPtr 56 | { 57 | return m_p_error; 58 | } 59 | 60 | bool CHResultException::HasError() const noexcept 61 | { 62 | return SUCCEEDED(m_hr); 63 | } 64 | 65 | auto CHResultException::GetHResult() const noexcept 66 | -> HRESULT 67 | { 68 | return m_hr; 69 | } 70 | 71 | void LogHResultException(CHResultException& ex) 72 | { 73 | auto str_hr = "HResult:" + std::to_string(ex.GetHResult()); 74 | CCommon::WriteLog(str_hr.c_str(), theApp.m_log_path.c_str()); 75 | auto* log = ex.what(); 76 | CCommon::WriteLog(log, theApp.m_log_path.c_str()); 77 | auto* p_error = ex.GetError().Get(); 78 | if (p_error == NULL) 79 | { 80 | return; 81 | } 82 | BSTR p_description{NULL}; 83 | ThrowIfFailed(p_error->GetDescription(&p_description), 84 | TRAFFICMONITOR_ERROR_STR("Get description from IErrorInfo failed.")); 85 | CCommon::WriteLog(p_description, theApp.m_log_path.c_str()); 86 | ::SysFreeString(p_description); 87 | } -------------------------------------------------------------------------------- /TrafficMonitor/CTabCtrlEx.cpp: -------------------------------------------------------------------------------- 1 | // CTabCtrlEx.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "CTabCtrlEx.h" 6 | 7 | 8 | // CTabCtrlEx 9 | 10 | IMPLEMENT_DYNAMIC(CTabCtrlEx, CTabCtrl) 11 | 12 | CTabCtrlEx::CTabCtrlEx() 13 | { 14 | 15 | } 16 | 17 | CTabCtrlEx::~CTabCtrlEx() 18 | { 19 | } 20 | 21 | void CTabCtrlEx::AddWindow(CWnd* pWnd, LPCTSTR lable_text) 22 | { 23 | if (pWnd == nullptr || pWnd->GetSafeHwnd() == NULL) 24 | return; 25 | 26 | InsertItem(m_tab_list.size(), lable_text, m_tab_list.size()); 27 | 28 | pWnd->SetParent(this); 29 | pWnd->MoveWindow(m_tab_rect); 30 | 31 | m_tab_list.push_back(pWnd); 32 | } 33 | 34 | void CTabCtrlEx::SetCurTab(int index) 35 | { 36 | if (index < 0 || index >= static_cast(m_tab_list.size())) 37 | index = 0; 38 | SetCurSel(index); 39 | 40 | int tab_size = m_tab_list.size(); 41 | for (int i = 0; i < tab_size; i++) 42 | { 43 | if (i == index) 44 | { 45 | m_tab_list[i]->ShowWindow(SW_SHOW); 46 | m_tab_list[i]->SetFocus(); 47 | } 48 | else 49 | { 50 | m_tab_list[i]->ShowWindow(SW_HIDE); 51 | } 52 | } 53 | } 54 | 55 | CWnd* CTabCtrlEx::GetCurrentTab() 56 | { 57 | int cur_tab_index = GetCurSel(); 58 | if (cur_tab_index >= 0 && cur_tab_index < m_tab_list.size()) 59 | { 60 | return m_tab_list[cur_tab_index]; 61 | } 62 | return nullptr; 63 | } 64 | 65 | void CTabCtrlEx::AdjustTabWindowSize() 66 | { 67 | CalSubWindowSize(); 68 | for (size_t i{}; i < m_tab_list.size(); i++) 69 | { 70 | m_tab_list[i]->MoveWindow(m_tab_rect); 71 | } 72 | } 73 | 74 | void CTabCtrlEx::CalSubWindowSize() 75 | { 76 | GetClientRect(m_tab_rect); 77 | CRect rc_temp = m_tab_rect; 78 | AdjustRect(FALSE, rc_temp); 79 | int margin = rc_temp.left - m_tab_rect.left; 80 | CRect rcTabItem; 81 | GetItemRect(0, rcTabItem); 82 | m_tab_rect.top += rcTabItem.Height() + margin; 83 | m_tab_rect.left += margin; 84 | m_tab_rect.bottom -= margin; 85 | m_tab_rect.right -= margin; 86 | } 87 | 88 | 89 | BEGIN_MESSAGE_MAP(CTabCtrlEx, CTabCtrl) 90 | ON_NOTIFY_REFLECT(TCN_SELCHANGE, &CTabCtrlEx::OnTcnSelchange) 91 | ON_WM_SIZE() 92 | END_MESSAGE_MAP() 93 | 94 | 95 | 96 | // CTabCtrlEx 消息处理程序 97 | 98 | 99 | 100 | 101 | void CTabCtrlEx::OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult) 102 | { 103 | // TODO: 在此添加控件通知处理程序代码 104 | int tab_selected = GetCurSel(); 105 | SetCurTab(tab_selected); 106 | 107 | *pResult = 0; 108 | } 109 | 110 | 111 | void CTabCtrlEx::PreSubclassWindow() 112 | { 113 | // TODO: 在此添加专用代码和/或调用基类 114 | 115 | //计算子窗口的位置 116 | CalSubWindowSize(); 117 | 118 | CTabCtrl::PreSubclassWindow(); 119 | } 120 | 121 | 122 | void CTabCtrlEx::OnSize(UINT nType, int cx, int cy) 123 | { 124 | CTabCtrl::OnSize(nType, cx, cy); 125 | 126 | // TODO: 在此处添加消息处理程序代码 127 | AdjustTabWindowSize(); 128 | } 129 | -------------------------------------------------------------------------------- /TrafficMonitor/WindowsSettingHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "WindowsSettingHelper.h" 3 | #include "TrafficMonitor.h" 4 | 5 | bool CWindowsSettingHelper::m_light_theme{}; 6 | bool CWindowsSettingHelper::IsWindows10LightTheme() 7 | { 8 | return m_light_theme; 9 | } 10 | 11 | void CWindowsSettingHelper::CheckWindows10LightTheme() 12 | { 13 | if (theApp.m_win_version.IsWindows10OrLater()) 14 | { 15 | HKEY hKey; 16 | DWORD dwThemeData(0); 17 | LONG lRes = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey); 18 | if (lRes == ERROR_SUCCESS) { 19 | GetDWORDRegKeyData(hKey, L"SystemUsesLightTheme", dwThemeData); 20 | m_light_theme = (dwThemeData != 0); 21 | } 22 | else 23 | { 24 | m_light_theme = false; 25 | } 26 | RegCloseKey(hKey); 27 | } 28 | else 29 | { 30 | m_light_theme = false; 31 | } 32 | } 33 | 34 | bool CWindowsSettingHelper::IsDotNetFramework4Point5Installed() 35 | { 36 | DWORD netFramewordRelease{}; 37 | if (!GetDWORDRegKeyData(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full", L"Release", netFramewordRelease)) 38 | return false; 39 | return netFramewordRelease >= 379893; 40 | } 41 | 42 | bool CWindowsSettingHelper::IsTaskbarWidgetsBtnShown() 43 | { 44 | DWORD data{}; 45 | if (!GetDWORDRegKeyData(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"TaskbarDa", data)) 46 | return true; 47 | return data != 0; 48 | } 49 | 50 | bool CWindowsSettingHelper::IsTaskbarCenterAlign() 51 | { 52 | DWORD data{}; 53 | if (!GetDWORDRegKeyData(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"TaskbarAl", data)) 54 | return true; 55 | return data != 0; 56 | } 57 | 58 | bool CWindowsSettingHelper::IsTaskbarShowingInAllDisplays() 59 | { 60 | DWORD data{}; 61 | if (!GetDWORDRegKeyData(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"MMTaskbarEnabled", data)) 62 | return false; 63 | return data != 0; 64 | } 65 | 66 | LONG CWindowsSettingHelper::GetDWORDRegKeyData(HKEY hKey, const wstring& strValueName, DWORD& dwValueData) 67 | { 68 | DWORD dwBufferSize(sizeof(DWORD)); 69 | DWORD dwResult(0); 70 | LONG lError = ::RegQueryValueExW(hKey, strValueName.c_str(), NULL, NULL, reinterpret_cast(&dwResult), &dwBufferSize); 71 | if (lError == ERROR_SUCCESS) 72 | dwValueData = dwResult; 73 | return lError; 74 | } 75 | 76 | bool CWindowsSettingHelper::GetDWORDRegKeyData(HKEY keyParent, const wstring& strKeyName, const wstring& strValueName, DWORD& dwValueData) 77 | { 78 | CRegKey key; 79 | if (key.Open(keyParent, strKeyName.c_str(), KEY_READ) != ERROR_SUCCESS) 80 | return false; 81 | return (key.QueryDWORDValue(strValueName.c_str(), dwValueData) == ERROR_SUCCESS); 82 | } 83 | -------------------------------------------------------------------------------- /TrafficMonitor/CAutoAdaptSettingsDlg.cpp: -------------------------------------------------------------------------------- 1 | // CAutoAdaptSettingsDlg.cpp: 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "CAutoAdaptSettingsDlg.h" 7 | #include "afxdialogex.h" 8 | 9 | 10 | // CAutoAdaptSettingsDlg 对话框 11 | 12 | IMPLEMENT_DYNAMIC(CAutoAdaptSettingsDlg, CDialog) 13 | 14 | CAutoAdaptSettingsDlg::CAutoAdaptSettingsDlg(TaskBarSettingData& data, CWnd* pParent /*=nullptr*/) 15 | : CDialog(IDD_ATUO_ADAPT_SETTING_DIALOG, pParent), m_data(data) 16 | { 17 | 18 | } 19 | 20 | CAutoAdaptSettingsDlg::~CAutoAdaptSettingsDlg() 21 | { 22 | } 23 | 24 | void CAutoAdaptSettingsDlg::InitComboBox(CComboBox& combo_box, int style_sel) 25 | { 26 | for (int i = 0; i < TASKBAR_DEFAULT_STYLE_NUM; i++) 27 | combo_box.AddString(CCommon::LoadText(IDS_PRESET, std::to_wstring(i + 1).c_str())); 28 | if (style_sel >= 0 && style_sel < TASKBAR_DEFAULT_STYLE_NUM) 29 | combo_box.SetCurSel(style_sel); 30 | else 31 | combo_box.SetCurSel(0); 32 | } 33 | 34 | int CAutoAdaptSettingsDlg::GetComboBoxSel(const CComboBox& combo_box) 35 | { 36 | int sel = combo_box.GetCurSel(); 37 | if (sel >= 0 && sel < TASKBAR_DEFAULT_STYLE_NUM) 38 | return sel; 39 | else 40 | return 0; 41 | } 42 | 43 | void CAutoAdaptSettingsDlg::DoDataExchange(CDataExchange* pDX) 44 | { 45 | CDialog::DoDataExchange(pDX); 46 | DDX_Control(pDX, IDC_DARK_MODE_DEFAULT_STYLE_COMBO, m_dark_mode_default_style_combo); 47 | DDX_Control(pDX, IDC_LIGHT_MODE_DEFAULT_STYLE_COMBO, m_light_mode_default_style_combo); 48 | } 49 | 50 | 51 | BEGIN_MESSAGE_MAP(CAutoAdaptSettingsDlg, CDialog) 52 | END_MESSAGE_MAP() 53 | 54 | 55 | // CAutoAdaptSettingsDlg 消息处理程序 56 | 57 | 58 | BOOL CAutoAdaptSettingsDlg::OnInitDialog() 59 | { 60 | CDialog::OnInitDialog(); 61 | 62 | // TODO: 在此添加额外的初始化 63 | InitComboBox(m_dark_mode_default_style_combo, m_data.dark_default_style); 64 | InitComboBox(m_light_mode_default_style_combo, m_data.light_default_style); 65 | CheckDlgButton(IDC_AUTO_SAVE_TO_PRESET_CHECK, m_data.auto_save_taskbar_color_settings_to_preset); 66 | 67 | m_toolTip.Create(this); 68 | m_toolTip.SetMaxTipWidth(theApp.DPI(300)); 69 | m_toolTip.AddTool(GetDlgItem(IDC_AUTO_SAVE_TO_PRESET_CHECK), CCommon::LoadText(IDS_AUTO_SAVE_TO_PRESET_TIP)); 70 | 71 | return TRUE; // return TRUE unless you set the focus to a control 72 | // 异常: OCX 属性页应返回 FALSE 73 | } 74 | 75 | 76 | void CAutoAdaptSettingsDlg::OnOK() 77 | { 78 | // TODO: 在此添加专用代码和/或调用基类 79 | 80 | //获取控件中的设置 81 | m_data.dark_default_style = GetComboBoxSel(m_dark_mode_default_style_combo); 82 | m_data.light_default_style = GetComboBoxSel(m_light_mode_default_style_combo); 83 | m_data.auto_save_taskbar_color_settings_to_preset = (IsDlgButtonChecked(IDC_AUTO_SAVE_TO_PRESET_CHECK) != 0); 84 | 85 | CDialog::OnOK(); 86 | } 87 | 88 | 89 | BOOL CAutoAdaptSettingsDlg::PreTranslateMessage(MSG* pMsg) 90 | { 91 | // TODO: 在此添加专用代码和/或调用基类 92 | if (pMsg->message == WM_MOUSEMOVE) 93 | m_toolTip.RelayEvent(pMsg); 94 | 95 | return CDialog::PreTranslateMessage(pMsg); 96 | } 97 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Release CI 2 | on: push 3 | jobs: 4 | x64_build: 5 | runs-on: windows-latest 6 | 7 | steps: 8 | - uses: actions/checkout@v3 9 | 10 | - name: Add msbuild to PATH 11 | uses: microsoft/setup-msbuild@v1.1.3 12 | 13 | - name: Run msbuild 14 | run: msbuild -p:configuration=release -p:platform=x64 -p:platformToolset=v142 15 | 16 | - name: Get current time 17 | uses: josStorer/get-current-time@v2.0.2 18 | id: current-time 19 | with: 20 | format: YYYYMMDD_HHmmss 21 | utcOffset: "+08:00" 22 | 23 | - name : Upload artifact 24 | uses: actions/upload-artifact@v3 25 | with: 26 | name: x64_${{ steps.current-time.outputs.formattedTime }}_TrafficMonitor 27 | path: | 28 | Bin/x64/Release/TrafficMonitor.exe 29 | Bin/x64/Release/*.dll 30 | 31 | - name : Upload pdb files 32 | uses: actions/upload-artifact@v3 33 | with: 34 | name: x64_${{ steps.current-time.outputs.formattedTime }}_pdb 35 | path: Bin/x64/Release/*.pdb 36 | 37 | x86_build: 38 | runs-on: windows-latest 39 | 40 | steps: 41 | - uses: actions/checkout@v3 42 | 43 | - name: Add msbuild to PATH 44 | uses: microsoft/setup-msbuild@v1.1.3 45 | 46 | - name: Run msbuild 47 | run: msbuild -p:configuration=release -p:platform=x86 -p:platformToolset=v142 48 | 49 | - name: Get current time 50 | uses: josStorer/get-current-time@v2.0.2 51 | id: current-time 52 | with: 53 | format: YYYYMMDD_HHmmss 54 | utcOffset: "+08:00" 55 | 56 | - name : Upload artifact 57 | uses: actions/upload-artifact@v3 58 | with: 59 | name: x86_${{ steps.current-time.outputs.formattedTime }}_TrafficMonitor 60 | path: | 61 | Bin/Release/TrafficMonitor.exe 62 | Bin/Release/*.dll 63 | 64 | - name : Upload pdb files 65 | uses: actions/upload-artifact@v3 66 | with: 67 | name: x86_${{ steps.current-time.outputs.formattedTime }}_pdb 68 | path: Bin/Release/*.pdb 69 | 70 | # winXP_build: 71 | # runs-on: windows-latest 72 | 73 | # steps: 74 | # - uses: actions/checkout@v3 75 | 76 | # - name: Add msbuild to PATH 77 | # uses: microsoft/setup-msbuild@v1.1.3 78 | 79 | # - name: Run msbuild 80 | # run: | 81 | # set ExternalCompilerOptions=/DCOMPILE_FOR_WINXP 82 | # msbuild -p:configuration=release -p:platform=x86 -p:platformToolset=v140_xp 83 | # shell: cmd 84 | 85 | # - name: Get current time 86 | # uses: josStorer/get-current-time@v2.0.2 87 | # id: current-time 88 | # with: 89 | # format: YYYYMMDD_HHmmss 90 | # utcOffset: "+08:00" 91 | 92 | # - name : Upload artifact 93 | # uses: actions/upload-artifact@v3 94 | # with: 95 | # name: winXP_${{ steps.current-time.outputs.formattedTime }}_TrafficMonitor 96 | # path: Bin/Release/TrafficMonitor.exe 97 | -------------------------------------------------------------------------------- /TrafficMonitor/IniHelper.h: -------------------------------------------------------------------------------- 1 | //ini读写类 2 | //使用时将ini文件路径通过构造函数参数传递 3 | //在向ini文件写入数据时,需要在最后调用Save()函数以将更改保存到文件 4 | //默认以UTF8_BOM编码保存,如果要以ANSI保存,请调用SetSaveAsUTF8(false); 5 | #pragma once 6 | #include "CommonData.h" 7 | #include "Common.h" 8 | 9 | class CIniHelper 10 | { 11 | public: 12 | CIniHelper(const wstring& file_path); 13 | ~CIniHelper(); 14 | 15 | void SetSaveAsUTF8(bool utf8); 16 | 17 | void WriteString(const wchar_t* AppName, const wchar_t* KeyName, const wstring& str); 18 | wstring GetString(const wchar_t* AppName, const wchar_t* KeyName, const wchar_t* default_str) const; 19 | void WriteInt(const wchar_t * AppName, const wchar_t * KeyName, int value); 20 | int GetInt(const wchar_t * AppName, const wchar_t * KeyName, int default_value) const; 21 | void WriteBool(const wchar_t * AppName, const wchar_t * KeyName, bool value); 22 | bool GetBool(const wchar_t * AppName, const wchar_t * KeyName, bool default_value) const; 23 | void WriteIntArray(const wchar_t * AppName, const wchar_t * KeyName, const int* values, int size); //写入一个int数组,元素个数为size 24 | void GetIntArray(const wchar_t * AppName, const wchar_t * KeyName, int* values, int size, int default_value = 0) const; //读取一个int数组,储存到values,元素个数为size 25 | void WriteBoolArray(const wchar_t * AppName, const wchar_t * KeyName, const bool* values, int size); 26 | void GetBoolArray(const wchar_t * AppName, const wchar_t * KeyName, bool* values, int size, bool default_value = false) const; 27 | void WriteStringList(const wchar_t* AppName, const wchar_t* KeyName, const vector& values); //写入一个字符串列表,由于保存到ini文件中时字符串前后会加上引号,所以字符串中不能包含引号 28 | void GetStringList(const wchar_t* AppName, const wchar_t* KeyName, vector& values, const vector& default_value) const; 29 | 30 | void SaveFontData(const wchar_t * AppName, const FontInfo& font); 31 | void LoadFontData(const wchar_t * AppName, FontInfo& font, const FontInfo& default_font) const; 32 | 33 | void LoadMainWndColors(const wchar_t * AppName, const wchar_t * KeyName, std::map& text_colors, COLORREF default_color); 34 | void SaveMainWndColors(const wchar_t * AppName, const wchar_t * KeyName, const std::map& text_colors); 35 | 36 | void LoadTaskbarWndColors(const wchar_t * AppName, const wchar_t * KeyName, std::map& text_colors, COLORREF default_color); 37 | void SaveTaskbarWndColors(const wchar_t * AppName, const wchar_t * KeyName, const std::map& text_colors); 38 | 39 | void LoadPluginDisplayStr(bool is_main_window); 40 | void SavePluginDisplayStr(bool is_main_window); 41 | 42 | bool Save(); //将ini文件保存到文件,成功返回true 43 | 44 | protected: 45 | wstring m_file_path; 46 | wstring m_ini_str; 47 | bool m_save_as_utf8{ true }; //是否以及UTF8编码保存 48 | 49 | void _WriteString(const wchar_t* AppName, const wchar_t* KeyName, const wstring& str); 50 | wstring _GetString(const wchar_t* AppName, const wchar_t* KeyName, const wchar_t* default_str) const; 51 | 52 | static wstring MergeStringList(const vector& values); 53 | static void SplitStringList(vector& values, wstring str_value); 54 | }; 55 | -------------------------------------------------------------------------------- /PluginDemo/PluginDemo.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "PluginDemo.h" 3 | #include "DataManager.h" 4 | #include "OptionsDlg.h" 5 | 6 | CPluginDemo CPluginDemo::m_instance; 7 | 8 | CPluginDemo::CPluginDemo() 9 | { 10 | } 11 | 12 | CPluginDemo& CPluginDemo::Instance() 13 | { 14 | return m_instance; 15 | } 16 | 17 | IPluginItem* CPluginDemo::GetItem(int index) 18 | { 19 | switch (index) 20 | { 21 | case 0: 22 | return &m_system_date; 23 | case 1: 24 | return &m_system_time; 25 | case 2: 26 | return &m_custom_draw_item; 27 | default: 28 | break; 29 | } 30 | return nullptr; 31 | } 32 | 33 | void CPluginDemo::DataRequired() 34 | { 35 | //获取时间和日期 36 | SYSTEMTIME& system_time{ CDataManager::Instance().m_system_time }; 37 | GetLocalTime(&system_time); 38 | wchar_t buff[128]; 39 | swprintf_s(buff, L"%d/%.2d/%.2d", system_time.wYear, system_time.wMonth, system_time.wDay); 40 | CDataManager::Instance().m_cur_date = buff; 41 | 42 | if (CDataManager::Instance().m_setting_data.show_second) 43 | swprintf_s(buff, L"%.2d:%.2d:%.2d", system_time.wHour, system_time.wMinute, system_time.wSecond); 44 | else 45 | swprintf_s(buff, L"%.2d:%.2d", system_time.wHour, system_time.wMinute); 46 | CDataManager::Instance().m_cur_time = buff; 47 | } 48 | 49 | const wchar_t* CPluginDemo::GetInfo(PluginInfoIndex index) 50 | { 51 | AFX_MANAGE_STATE(AfxGetStaticModuleState()); 52 | static CString str; 53 | switch (index) 54 | { 55 | case TMI_NAME: 56 | str.LoadString(IDS_PLUGIN_NAME); 57 | return str.GetString(); 58 | case TMI_DESCRIPTION: 59 | str.LoadString(IDS_PLUGIN_DESCRIPTION); 60 | return str.GetString(); 61 | case TMI_AUTHOR: 62 | return L"zhongyang219"; 63 | case TMI_COPYRIGHT: 64 | return L"Copyright (C) by Zhong Yang 2021"; 65 | case TMI_VERSION: 66 | return L"1.0"; 67 | case ITMPlugin::TMI_URL: 68 | return L"https://github.com/zhongyang219/TrafficMonitor"; 69 | break; 70 | default: 71 | break; 72 | } 73 | return L""; 74 | } 75 | 76 | ITMPlugin::OptionReturn CPluginDemo::ShowOptionsDialog(void* hParent) 77 | { 78 | AFX_MANAGE_STATE(AfxGetStaticModuleState()); 79 | COptionsDlg dlg(CWnd::FromHandle((HWND)hParent)); 80 | dlg.m_data = CDataManager::Instance().m_setting_data; 81 | if (dlg.DoModal() == IDOK) 82 | { 83 | CDataManager::Instance().m_setting_data = dlg.m_data; 84 | return ITMPlugin::OR_OPTION_CHANGED; 85 | } 86 | return ITMPlugin::OR_OPTION_UNCHANGED; 87 | } 88 | 89 | 90 | void CPluginDemo::OnExtenedInfo(ExtendedInfoIndex index, const wchar_t* data) 91 | { 92 | switch (index) 93 | { 94 | case ITMPlugin::EI_CONFIG_DIR: 95 | //从配置文件读取配置 96 | g_data.LoadConfig(std::wstring(data)); 97 | 98 | break; 99 | default: 100 | break; 101 | } 102 | } 103 | 104 | ITMPlugin* TMPluginGetInstance() 105 | { 106 | AFX_MANAGE_STATE(AfxGetStaticModuleState()); 107 | return &CPluginDemo::Instance(); 108 | } 109 | -------------------------------------------------------------------------------- /TrafficMonitor/MainWndColorDlg.cpp: -------------------------------------------------------------------------------- 1 | // MainWndColorDlg.cpp : 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "MainWndColorDlg.h" 7 | #include "afxdialogex.h" 8 | #include "CMFCColorDialogEx.h" 9 | 10 | 11 | // CMainWndColorDlg 对话框 12 | 13 | IMPLEMENT_DYNAMIC(CMainWndColorDlg, CBaseDialog) 14 | 15 | CMainWndColorDlg::CMainWndColorDlg(const std::map& colors, CWnd* pParent /*=NULL*/) 16 | : CBaseDialog(IDD_MAIN_COLOR_DIALOG, pParent), m_colors(colors) 17 | { 18 | } 19 | 20 | CMainWndColorDlg::~CMainWndColorDlg() 21 | { 22 | } 23 | 24 | CString CMainWndColorDlg::GetDialogName() const 25 | { 26 | return _T("MainWndColorDlg"); 27 | } 28 | 29 | void CMainWndColorDlg::DoDataExchange(CDataExchange* pDX) 30 | { 31 | CBaseDialog::DoDataExchange(pDX); 32 | DDX_Control(pDX, IDC_LIST1, m_list_ctrl); 33 | } 34 | 35 | 36 | BEGIN_MESSAGE_MAP(CMainWndColorDlg, CBaseDialog) 37 | ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CMainWndColorDlg::OnNMDblclkList1) 38 | END_MESSAGE_MAP() 39 | 40 | 41 | // CMainWndColorDlg 消息处理程序 42 | 43 | 44 | BOOL CMainWndColorDlg::OnInitDialog() 45 | { 46 | CBaseDialog::OnInitDialog(); 47 | 48 | // TODO: 在此添加额外的初始化 49 | 50 | SetIcon(theApp.GetMenuIcon(IDI_MAIN_WINDOW), FALSE); // 设置小图标 51 | 52 | //初始化列表控件 53 | CRect rect; 54 | m_list_ctrl.GetClientRect(rect); 55 | m_list_ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); 56 | int width0, width1; 57 | width0 = rect.Width() * 2 / 3; 58 | width1 = rect.Width() - width0 - theApp.DPI(20) - 1; 59 | m_list_ctrl.InsertColumn(0, CCommon::LoadText(IDS_ITEM), LVCFMT_LEFT, width0); //插入第0列 60 | m_list_ctrl.InsertColumn(1, CCommon::LoadText(IDS_COLOR), LVCFMT_LEFT, width1); //插入第1列 61 | m_list_ctrl.SetDrawItemRangMargin(theApp.DPI(2)); 62 | 63 | //向列表中插入行 64 | for (auto iter = theApp.m_plugins.AllDisplayItemsWithPlugins().begin(); iter != theApp.m_plugins.AllDisplayItemsWithPlugins().end(); ++iter) 65 | { 66 | CString item_name = iter->GetItemName(); 67 | if (!item_name.IsEmpty()) 68 | { 69 | int index = m_list_ctrl.GetItemCount(); 70 | m_list_ctrl.InsertItem(index, item_name); 71 | m_list_ctrl.SetItemColor(index, 1, m_colors[*iter]); 72 | m_list_ctrl.SetItemData(index, (DWORD_PTR)&(*iter)); 73 | } 74 | } 75 | 76 | 77 | return TRUE; // return TRUE unless you set the focus to a control 78 | // 异常: OCX 属性页应返回 FALSE 79 | } 80 | 81 | 82 | 83 | void CMainWndColorDlg::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult) 84 | { 85 | LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); 86 | // TODO: 在此添加控件通知处理程序代码 87 | int index = pNMItemActivate->iItem; 88 | COLORREF color = m_list_ctrl.GetItemColor(index, 1); 89 | CMFCColorDialogEx colorDlg(color, 0, this); 90 | if (colorDlg.DoModal() == IDOK) 91 | { 92 | color = colorDlg.GetColor(); 93 | m_list_ctrl.SetItemColor(index, 1, color); 94 | CommonDisplayItem* item = (CommonDisplayItem*)(m_list_ctrl.GetItemData(index)); 95 | m_colors[*item] = color; 96 | } 97 | 98 | *pResult = 0; 99 | } 100 | -------------------------------------------------------------------------------- /OpenHardwareMonitorApi/OpenHardwareMonitorImp.h: -------------------------------------------------------------------------------- 1 | // OpenHardwareMonitorApi.h 2 | 3 | #pragma once 4 | #include 5 | #include "OpenHardwareMonitor/OpenHardwareMonitorApi.h" 6 | #include "UpdateVisitor.h" 7 | #include 8 | 9 | using namespace System; 10 | using namespace LibreHardwareMonitor::Hardware; 11 | 12 | namespace OpenHardwareMonitorApi { 13 | 14 | public class COpenHardwareMonitor : public IOpenHardwareMonitor 15 | { 16 | public: 17 | COpenHardwareMonitor(); 18 | virtual ~COpenHardwareMonitor(); 19 | 20 | virtual void GetHardwareInfo() override; 21 | virtual float CpuTemperature() override; 22 | virtual float GpuTemperature() override; 23 | virtual float HDDTemperature() override; 24 | virtual float MainboardTemperature() override; 25 | virtual float GpuUsage() override; 26 | virtual float CpuFreq() override; 27 | virtual const std::map& AllHDDTemperature() override; 28 | virtual const std::map& AllCpuTemperature() override; 29 | virtual const std::map& AllHDDUsage() override; 30 | 31 | virtual void SetCpuEnable(bool enable) override; 32 | virtual void SetGpuEnable(bool enable) override; 33 | virtual void SetHddEnable(bool enable) override; 34 | virtual void SetMainboardEnable(bool enable) override; 35 | 36 | private: 37 | bool GetHardwareTemperature(IHardware^ hardware, float& temperature); 38 | bool GetCpuTemperature(IHardware^ hardware, float& temperature); 39 | bool GetGpuUsage(IHardware^ hardware, float& gpu_usage); 40 | bool GetHddUsage(IHardware^ hardware, float& hdd_usage); 41 | bool GetCPUFreq(IHardware^ hardware, float& freq); 42 | void ResetAllValues(); 43 | //向map中插入一个数值,如果key已经存在,则自动对新插入的key重命名 44 | static void InsertValueToMap(std::map& value_map, const std::wstring& key, float value); 45 | 46 | private: 47 | float m_cpu_temperature{}; 48 | float m_gpu_nvidia_temperature{}; 49 | float m_gpu_ati_temperature{}; 50 | float m_gpu_intel_temperature{}; 51 | float m_hdd_temperature{}; 52 | float m_main_board_temperature{}; 53 | float m_gpu_nvidia_usage{}; 54 | float m_gpu_ati_usage{}; 55 | float m_gpu_intel_usage{}; 56 | float m_cpu_freq{}; 57 | std::map m_all_hdd_temperature; 58 | std::map m_all_cpu_temperature; 59 | std::map m_all_cpu_clock; 60 | std::map m_all_hdd_usage; 61 | }; 62 | 63 | //一个单实例类 64 | //由于COpenHardwareMonitor是非托管类,不能将托管类的对象作为成员变量,此类用于保存托管类的对象 65 | public ref class MonitorGlobal 66 | { 67 | public: 68 | MonitorGlobal(); 69 | ~MonitorGlobal(); 70 | static MonitorGlobal^ Instance() 71 | { 72 | if (m_instance == nullptr) 73 | { 74 | m_instance = gcnew MonitorGlobal(); 75 | } 76 | return m_instance; 77 | } 78 | 79 | void Init(); 80 | void UnInit(); 81 | 82 | Computer^ computer; 83 | UpdateVisitor^ updateVisitor{}; 84 | 85 | private: 86 | static MonitorGlobal^ m_instance{}; 87 | }; 88 | } 89 | -------------------------------------------------------------------------------- /TrafficMonitor/HistoryTrafficListCtrl.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "HistoryTrafficListCtrl.h" 3 | 4 | IMPLEMENT_DYNAMIC(CHistoryTrafficListCtrl, CListCtrl) 5 | 6 | CHistoryTrafficListCtrl::CHistoryTrafficListCtrl() 7 | { 8 | } 9 | 10 | 11 | CHistoryTrafficListCtrl::~CHistoryTrafficListCtrl() 12 | { 13 | } 14 | void CHistoryTrafficListCtrl::SetDrawItemRangeData(int item, double range, COLORREF color) 15 | { 16 | if (item < 0) return; 17 | if (item >= static_cast(m_item_rage_data.size())) 18 | m_item_rage_data.resize(item + 1); 19 | m_item_rage_data[item].data_value = range; 20 | m_item_rage_data[item].color = color; 21 | } 22 | 23 | void CHistoryTrafficListCtrl::SetDrawItemRangInLogScale(bool log_scale) 24 | { 25 | m_use_log_scale = log_scale; 26 | Invalidate(); 27 | } 28 | 29 | BEGIN_MESSAGE_MAP(CHistoryTrafficListCtrl, CListCtrl) 30 | ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CHistoryTrafficListCtrl::OnNMCustomdraw) 31 | END_MESSAGE_MAP() 32 | 33 | 34 | void CHistoryTrafficListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) 35 | { 36 | if (m_draw_item_range) 37 | { 38 | *pResult = CDRF_DODEFAULT; 39 | LPNMLVCUSTOMDRAW lplvdr = reinterpret_cast(pNMHDR); 40 | NMCUSTOMDRAW& nmcd = lplvdr->nmcd; 41 | switch (lplvdr->nmcd.dwDrawStage) //判断状态 42 | { 43 | case CDDS_PREPAINT: 44 | *pResult = CDRF_NOTIFYITEMDRAW; 45 | break; 46 | case CDDS_ITEMPREPAINT: //如果为画ITEM之前就要进行颜色的改变 47 | if (nmcd.dwItemSpec >= 0 && nmcd.dwItemSpec < m_item_rage_data.size()) 48 | { 49 | double range = m_item_rage_data[nmcd.dwItemSpec].data_value; 50 | CDC* pDC = CDC::FromHandle(nmcd.hdc); //获取绘图DC 51 | CRect item_rect, draw_rect; 52 | GetSubItemRect(nmcd.dwItemSpec,m_draw_item_range_row, LVIR_BOUNDS, item_rect); //获取绘图单元格的矩形区域 53 | CDrawCommon::SetDrawRect(pDC, item_rect); //设置绘图区域为当前列 54 | //使用双缓冲绘图 55 | { 56 | CDrawDoubleBuffer draw_double_buffer(pDC, item_rect); 57 | //填充背景 58 | draw_rect = item_rect; 59 | draw_rect.MoveToXY(0, 0); 60 | draw_double_buffer.GetMemDC()->FillSolidRect(draw_rect, GetSysColor(COLOR_WINDOW)); 61 | if (draw_rect.Height() > 2 * m_margin) 62 | { 63 | draw_rect.top += m_margin; 64 | draw_rect.bottom -= m_margin; 65 | } 66 | int width; 67 | if (m_use_log_scale) //使用对数比例(y=ln(x+1)) 68 | { 69 | range = std::log(range + 1); 70 | width = static_cast(range*draw_rect.Width() / std::log(1000 + 1)); 71 | } 72 | else //使用线性比例(y=x) 73 | { 74 | width = static_cast(range*draw_rect.Width() / 1000); 75 | } 76 | draw_rect.right = draw_rect.left + width; 77 | draw_double_buffer.GetMemDC()->FillSolidRect(draw_rect, m_item_rage_data[nmcd.dwItemSpec].color); 78 | } 79 | 80 | //当前列绘制完成后将绘图区域设置为左边的区域,防止当前列的区域被覆盖 81 | CRect rect1{ item_rect }; 82 | rect1.left = 0; 83 | rect1.right = item_rect.left; 84 | CDrawCommon::SetDrawRect(pDC, rect1); 85 | } 86 | *pResult = CDRF_DODEFAULT; 87 | break; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /TrafficMonitor/FilePathHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "FilePathHelper.h" 3 | #include "Common.h" 4 | 5 | 6 | CFilePathHelper::CFilePathHelper(const wstring & file_path) 7 | : m_file_path{ file_path } 8 | { 9 | } 10 | 11 | CFilePathHelper::~CFilePathHelper() 12 | { 13 | } 14 | 15 | wstring CFilePathHelper::GetFileExtension(bool upper, bool width_dot) const 16 | { 17 | size_t index; 18 | index = m_file_path.rfind('.'); 19 | if (index == wstring::npos || index == m_file_path.size() - 1) 20 | return wstring(); 21 | wstring file_extension{ m_file_path.substr(width_dot ? index : index + 1) }; 22 | CCommon::StringTransform(file_extension, upper); 23 | return file_extension; 24 | } 25 | 26 | wstring CFilePathHelper::GetFileName() const 27 | { 28 | size_t index; 29 | index = m_file_path.rfind('\\'); 30 | if (index == wstring::npos) 31 | index = m_file_path.rfind('/'); 32 | return m_file_path.substr(index + 1); 33 | } 34 | 35 | wstring CFilePathHelper::GetFileNameWithoutExtension() const 36 | { 37 | size_t index, index1; 38 | index = m_file_path.rfind('.'); 39 | index1 = m_file_path.rfind('\\'); 40 | if (index1 == wstring::npos) 41 | index1 = m_file_path.rfind('/'); 42 | return m_file_path.substr(index1 + 1, (index - index1 - 1)); 43 | } 44 | 45 | wstring CFilePathHelper::GetFolderName() const 46 | { 47 | int index, index1; 48 | index = m_file_path.find_last_of(L"\\/"); 49 | if (index == wstring::npos || index == 0) 50 | return wstring(); 51 | 52 | index1 = m_file_path.find_last_of(L"\\/", index - 1); 53 | if (index1 == wstring::npos || index1 == 0) 54 | return wstring(); 55 | 56 | return m_file_path.substr(index1 + 1, (index - index1 - 1)); 57 | } 58 | 59 | wstring CFilePathHelper::GetDir() const 60 | { 61 | if (!m_file_path.empty() && (m_file_path.back() == L'\\' || m_file_path.back() == L'/')) 62 | return m_file_path; 63 | size_t index; 64 | index = m_file_path.rfind('\\'); 65 | if (index == wstring::npos) 66 | index = m_file_path.rfind('/'); 67 | return m_file_path.substr(0, index + 1); 68 | } 69 | 70 | wstring CFilePathHelper::GetParentDir() const 71 | { 72 | wstring dir{ GetDir() }; 73 | size_t index; 74 | if (!dir.empty() && (dir.back() == L'\\' || dir.back() == L'/')) 75 | dir.pop_back(); 76 | index = dir.rfind('\\'); 77 | if (index == wstring::npos) 78 | index = dir.rfind('/'); 79 | return m_file_path.substr(0, index + 1); 80 | } 81 | 82 | const wstring& CFilePathHelper::ReplaceFileExtension(const wchar_t * new_extension) 83 | { 84 | size_t index, index1; 85 | index = m_file_path.rfind('.'); 86 | index1 = m_file_path.rfind('\\'); 87 | if (index == wstring::npos || (index1 != wstring::npos && index < index1)) //如果没有找到“.”,或者“.”在反斜杠的左边,则在末尾添加一个“.” 88 | { 89 | m_file_path.push_back(L'.'); 90 | } 91 | else if (index != m_file_path.size() - 1) //如果“.”不在最后的位置,则删除“.”后面的字符串 92 | { 93 | m_file_path.erase(index + 1); 94 | } 95 | if (new_extension == nullptr || *new_extension == L'\0') 96 | { 97 | if (!m_file_path.empty() && m_file_path.back() == L'.') 98 | m_file_path.pop_back(); 99 | } 100 | else 101 | { 102 | m_file_path.append(new_extension); //在末尾添加扩展名 103 | } 104 | return m_file_path; 105 | } 106 | 107 | wstring CFilePathHelper::GetFilePathWithoutExtension() const 108 | { 109 | size_t index; 110 | index = m_file_path.rfind('.'); 111 | return m_file_path.substr(0, index); 112 | } 113 | -------------------------------------------------------------------------------- /TrafficMonitor/DllFunctions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include // 包含::GetDpiForMonitor 3 | #include // 包含D3DCompile 4 | #include // 包含DCompositionCreateDevice 5 | #include // 包含CreateDXGIFactory2 6 | #include 7 | #include 8 | 9 | template 10 | class CDllFunction 11 | #ifdef WIN32 12 | { 13 | // workaround for MSVC 19.34.31933 target x86 14 | 15 | private: 16 | FunctionPointer m_p_function{nullptr}; 17 | HMODULE m_h_dll; 18 | 19 | public: 20 | CDllFunction(LPCTSTR dll_name, LPCSTR function_name) noexcept 21 | { 22 | m_h_dll = ::LoadLibrary(dll_name); 23 | if (m_h_dll != NULL) 24 | { 25 | m_p_function = (FunctionPointer)::GetProcAddress(m_h_dll, function_name); 26 | if (m_p_function == nullptr) 27 | { 28 | ::FreeLibrary(m_h_dll); 29 | m_h_dll = NULL; 30 | } 31 | } 32 | } 33 | ~CDllFunction() noexcept 34 | { 35 | if (m_h_dll != NULL) 36 | { 37 | ::FreeLibrary(m_h_dll); 38 | m_h_dll = NULL; 39 | } 40 | } 41 | template 42 | auto operator()(Args&&... args) const 43 | { 44 | return m_p_function(std::forward(args)...); 45 | } 46 | bool HasValue() const noexcept 47 | { 48 | return m_p_function != nullptr; 49 | } 50 | } 51 | #endif 52 | ; 53 | /** 54 | * @brief 可以自动管理HMODULE生命周期,并自动尝试加载指定函数的类 55 | 使用示例: 56 | 定义:CDllFunction GetDpiForMonitor{_T("Shcore.dll"), "GetDpiForMonitor"}; 57 | 使用:(某个类或者命名空间)::GetDpiForMonitor(所需的参数); 58 | 当然,变量GetDpiForMonitor不能暴露在全局命名空间内。 59 | * 60 | * @tparam R 函数返回值 61 | * @tparam Args 函数参数 62 | */ 63 | template 64 | class CDllFunction 65 | { 66 | using FunctionPointer = R (*)(Args...); 67 | 68 | private: 69 | FunctionPointer m_p_function{nullptr}; 70 | HMODULE m_h_dll; 71 | 72 | public: 73 | CDllFunction(LPCTSTR dll_name, LPCSTR function_name) noexcept 74 | { 75 | m_h_dll = ::LoadLibrary(dll_name); 76 | if (m_h_dll != NULL) 77 | { 78 | m_p_function = (FunctionPointer)::GetProcAddress(m_h_dll, function_name); 79 | if (m_p_function == nullptr) 80 | { 81 | ::FreeLibrary(m_h_dll); 82 | m_h_dll = NULL; 83 | } 84 | } 85 | } 86 | ~CDllFunction() noexcept 87 | { 88 | if (m_h_dll != NULL) 89 | { 90 | ::FreeLibrary(m_h_dll); 91 | m_h_dll = NULL; 92 | } 93 | } 94 | R operator()(Args... args) const 95 | { 96 | return m_p_function(args...); 97 | } 98 | bool HasValue() const noexcept 99 | { 100 | return m_p_function != nullptr; 101 | } 102 | }; 103 | 104 | typedef HRESULT(WINAPI* _GetDpiForMonitor)(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT* dpiX, UINT* dpiY); 105 | 106 | class CDllFunctions 107 | { 108 | public: 109 | CDllFunctions(); 110 | ~CDllFunctions(); 111 | 112 | public: 113 | HRESULT GetDpiForMonitor(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT* dpiX, UINT* dpiY); 114 | static const CDllFunction D3DCompile; 115 | static const CDllFunction DCompositionCreateDevice; 116 | static const CDllFunction CreateDXGIFactory2; 117 | 118 | private: 119 | _GetDpiForMonitor m_getDpiForMonitor{}; 120 | 121 | private: 122 | HMODULE m_shcore_module{}; 123 | }; 124 | -------------------------------------------------------------------------------- /TrafficMonitor/TaskbarColorDlg.cpp: -------------------------------------------------------------------------------- 1 | // TaskbarColorDlg.cpp : 实现文件 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "TrafficMonitor.h" 6 | #include "TaskbarColorDlg.h" 7 | #include "afxdialogex.h" 8 | #include "CMFCColorDialogEx.h" 9 | 10 | 11 | // CTaskbarColorDlg 对话框 12 | 13 | IMPLEMENT_DYNAMIC(CTaskbarColorDlg, CBaseDialog) 14 | 15 | CTaskbarColorDlg::CTaskbarColorDlg(const std::map& colors, CWnd* pParent /*=NULL*/) 16 | : CBaseDialog(IDD_TASKBAR_COLOR_DIALOG, pParent), m_colors(colors) 17 | { 18 | } 19 | 20 | CTaskbarColorDlg::~CTaskbarColorDlg() 21 | { 22 | } 23 | 24 | CString CTaskbarColorDlg::GetDialogName() const 25 | { 26 | return _T("TaskbarColorDlg"); 27 | } 28 | 29 | void CTaskbarColorDlg::DoDataExchange(CDataExchange* pDX) 30 | { 31 | CBaseDialog::DoDataExchange(pDX); 32 | DDX_Control(pDX, IDC_LIST1, m_list_ctrl); 33 | } 34 | 35 | 36 | BEGIN_MESSAGE_MAP(CTaskbarColorDlg, CBaseDialog) 37 | ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CTaskbarColorDlg::OnNMDblclkList1) 38 | END_MESSAGE_MAP() 39 | 40 | 41 | // CTaskbarColorDlg 消息处理程序 42 | 43 | 44 | BOOL CTaskbarColorDlg::OnInitDialog() 45 | { 46 | CBaseDialog::OnInitDialog(); 47 | 48 | // TODO: 在此添加额外的初始化 49 | 50 | SetIcon(theApp.GetMenuIcon(IDI_TASKBAR_WINDOW), FALSE); // 设置小图标 51 | 52 | //初始化列表控件 53 | CRect rect; 54 | m_list_ctrl.GetClientRect(rect); 55 | m_list_ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); 56 | int width0 = rect.Width() /2; 57 | int width1 = (rect.Width() - width0 - theApp.DPI(20) - 1) / 2; 58 | int width2 = rect.Width() - width0 - width1 - theApp.DPI(20) - 1; 59 | m_list_ctrl.InsertColumn(0, CCommon::LoadText(IDS_ITEM), LVCFMT_LEFT, width0); 60 | m_list_ctrl.InsertColumn(1, CCommon::LoadText(IDS_COLOR_LABEL), LVCFMT_LEFT, width1); 61 | m_list_ctrl.InsertColumn(2, CCommon::LoadText(IDS_COLOR_VALUE), LVCFMT_LEFT, width2); 62 | m_list_ctrl.SetDrawItemRangMargin(theApp.DPI(2)); 63 | 64 | //向列表中插入行 65 | for (auto iter = theApp.m_plugins.AllDisplayItemsWithPlugins().begin(); iter != theApp.m_plugins.AllDisplayItemsWithPlugins().end(); ++iter) 66 | { 67 | CString item_name = iter->GetItemName(); 68 | if (!item_name.IsEmpty()) 69 | { 70 | int index = m_list_ctrl.GetItemCount(); 71 | m_list_ctrl.InsertItem(index, item_name); 72 | m_list_ctrl.SetItemColor(index, 1, m_colors[*iter].label); 73 | m_list_ctrl.SetItemColor(index, 2, m_colors[*iter].value); 74 | m_list_ctrl.SetItemData(index, (DWORD_PTR)&(*iter)); 75 | } 76 | } 77 | 78 | return TRUE; // return TRUE unless you set the focus to a control 79 | // 异常: OCX 属性页应返回 FALSE 80 | } 81 | 82 | 83 | 84 | void CTaskbarColorDlg::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult) 85 | { 86 | LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); 87 | // TODO: 在此添加控件通知处理程序代码 88 | int index = pNMItemActivate->iItem; 89 | int col = pNMItemActivate->iSubItem; 90 | if (col == 1 || col == 2) 91 | { 92 | COLORREF color = m_list_ctrl.GetItemColor(index, col); 93 | CMFCColorDialogEx colorDlg(color, 0, this); 94 | if (colorDlg.DoModal() == IDOK) 95 | { 96 | color = colorDlg.GetColor(); 97 | m_list_ctrl.SetItemColor(index, col, color); 98 | CommonDisplayItem* item = (CommonDisplayItem*)(m_list_ctrl.GetItemData(index)); 99 | if (col == 1) 100 | m_colors[*item].label = color; 101 | else 102 | m_colors[*item].value = color; 103 | } 104 | } 105 | 106 | *pResult = 0; 107 | } 108 | -------------------------------------------------------------------------------- /TrafficMonitor/D2D1Support.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "D2D1Support.h" 3 | #include "Common.h" 4 | 5 | #pragma comment(lib, "D2d1.lib") 6 | #pragma comment(lib, "Dwrite.lib") 7 | 8 | bool CD2D1Support::CheckSupport() 9 | { 10 | static bool result = FunctionChecker::CheckFunctionExist(_T("D2d1.dll"), "D2D1CreateFactory"); 11 | return result; 12 | } 13 | 14 | ID2D1Factory* CD2D1Support::GetFactory() 15 | { 16 | static auto result = MakeStaticVariableWrapper( 17 | [](ID2D1Factory** pp_factory) 18 | { 19 | *pp_factory = nullptr; 20 | 21 | ThrowIfFailed(::D2D1CreateFactory( 22 | D2D1_FACTORY_TYPE_SINGLE_THREADED, 23 | CD2D1Support::CREATION_OPTIONS, 24 | pp_factory), 25 | TRAFFICMONITOR_ERROR_STR("Create D2D1 factory failed.")); 26 | }, 27 | [](ID2D1Factory** pp_factory) 28 | { 29 | auto* p_factory = *pp_factory; 30 | RELEASE_COM(p_factory); 31 | }); 32 | return result.Get(); 33 | } 34 | 35 | bool CD2D1Support1::CheckSupport() 36 | { 37 | static bool result = FunctionChecker::CheckFunctionExist(_T("D2D1.dll"), "D2D1CreateDevice"); 38 | return result; 39 | } 40 | 41 | ID2D1Factory1* CD2D1Support1::GetFactory() 42 | { 43 | static auto result = MakeStaticVariableWrapper( 44 | [](auto pp_factory) 45 | { 46 | *pp_factory = nullptr; 47 | 48 | ThrowIfFailed(::D2D1CreateFactory( 49 | D2D1_FACTORY_TYPE_SINGLE_THREADED, 50 | CD2D1Support::CREATION_OPTIONS, 51 | pp_factory), 52 | TRAFFICMONITOR_ERROR_STR("Create D2D1 factory failed.")); 53 | }, 54 | [](auto pp_factory) 55 | { 56 | auto* p_factory = *pp_factory; 57 | RELEASE_COM(p_factory); 58 | }); 59 | return result.Get(); 60 | } 61 | 62 | void CD2D1Device::Recreate(Microsoft::WRL::ComPtr p_dxgi_device) 63 | { 64 | ThrowIfFailed( 65 | CD2D1Support1::GetFactory()->CreateDevice( 66 | p_dxgi_device.Get(), 67 | &m_p_device), 68 | TRAFFICMONITOR_ERROR_STR("Create ID2D1Device failed.")); 69 | 70 | NotifyAllResourceWhenDeviceRecreate( 71 | m_resource_tracker, 72 | m_p_device); 73 | } 74 | 75 | auto CD2D1Device::GetStorage() 76 | -> std::shared_ptr 77 | { 78 | return m_resource_tracker.GetSharedResourceTrackerStorage(); 79 | } 80 | 81 | auto CD2D1Device::Get() 82 | -> Type 83 | { 84 | return m_p_device; 85 | } 86 | 87 | bool CDWriteSupport::CheckSupport() 88 | { 89 | static bool result = FunctionChecker::CheckFunctionExist(_T("Dwrite.dll"), "DWriteCreateFactory"); 90 | return result; 91 | } 92 | 93 | IDWriteFactory* CDWriteSupport::GetFactory() 94 | { 95 | static auto result = MakeStaticVariableWrapper( 96 | [](IDWriteFactory** pp_factory) 97 | { 98 | *pp_factory = nullptr; 99 | ThrowIfFailed(::DWriteCreateFactory( 100 | DWRITE_FACTORY_TYPE_SHARED, 101 | __uuidof(IDWriteFactory), 102 | reinterpret_cast(pp_factory)), 103 | TRAFFICMONITOR_ERROR_STR("Create DWrite factory failed.")); 104 | }, 105 | [](IDWriteFactory** pp_factory) 106 | { 107 | auto* p_factory = *pp_factory; 108 | RELEASE_COM(p_factory); 109 | }); 110 | return result.Get(); 111 | } 112 | --------------------------------------------------------------------------------