diff --git a/PluginDemo/OptionsDlg.cpp b/PluginDemo/OptionsDlg.cpp
new file mode 100644
index 000000000..2de61fff7
--- /dev/null
+++ b/PluginDemo/OptionsDlg.cpp
@@ -0,0 +1,34 @@
+// OptionsDlg.cpp: 实现文件
+//
+
+#include "pch.h"
+#include "PluginDemo.h"
+#include "OptionsDlg.h"
+#include "afxdialogex.h"
+
+
+// COptionsDlg 对话框
+
+IMPLEMENT_DYNAMIC(COptionsDlg, CDialog)
+
+COptionsDlg::COptionsDlg(CWnd* pParent /*=nullptr*/)
+ : CDialog(IDD_OPTIONS_DIALOG, pParent)
+{
+
+}
+
+COptionsDlg::~COptionsDlg()
+{
+}
+
+void COptionsDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(COptionsDlg, CDialog)
+END_MESSAGE_MAP()
+
+
+// COptionsDlg 消息处理程序
diff --git a/PluginDemo/OptionsDlg.h b/PluginDemo/OptionsDlg.h
new file mode 100644
index 000000000..78284e8dd
--- /dev/null
+++ b/PluginDemo/OptionsDlg.h
@@ -0,0 +1,23 @@
+#pragma once
+
+
+// COptionsDlg 对话框
+
+class COptionsDlg : public CDialog
+{
+ DECLARE_DYNAMIC(COptionsDlg)
+
+public:
+ COptionsDlg(CWnd* pParent = nullptr); // 标准构造函数
+ virtual ~COptionsDlg();
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_OPTIONS_DIALOG };
+#endif
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/PluginDemo/PluginDemo.h b/PluginDemo/PluginDemo.h
index 06c0c173b..89b27d8d9 100644
--- a/PluginDemo/PluginDemo.h
+++ b/PluginDemo/PluginDemo.h
@@ -7,6 +7,7 @@ extern "C" {
__declspec(dllexport) IPluginItem* TMPluginCreateInstance(int index);
__declspec(dllexport) void TMPluginInfoRequired();
+ __declspec(dllexport) void TMPluginOptions();
#ifdef __cplusplus
}
diff --git a/PluginDemo/PluginDemo.rc b/PluginDemo/PluginDemo.rc
new file mode 100644
index 000000000..441f402c4
--- /dev/null
+++ b/PluginDemo/PluginDemo.rc
@@ -0,0 +1,106 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// (壬й) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+#pragma code_page(936)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS_DIALOG DIALOGEX 0, 0, 310, 178
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "ʱں"
+FONT 9, "ź", 400, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "ȷ",IDOK,199,157,50,14
+ PUSHBUTTON "ȡ",IDCANCEL,253,157,50,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 303
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 171
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTIONS_DIALOG AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // (壬й) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/PluginDemo/PluginDemo.vcxproj b/PluginDemo/PluginDemo.vcxproj
index 4f70113c7..c0a9fec79 100644
--- a/PluginDemo/PluginDemo.vcxproj
+++ b/PluginDemo/PluginDemo.vcxproj
@@ -31,6 +31,7 @@
true
v142
Unicode
+ Dynamic
DynamicLibrary
@@ -38,12 +39,14 @@
v142
true
Unicode
+ Dynamic
DynamicLibrary
true
v142
Unicode
+ Dynamic
DynamicLibrary
@@ -51,6 +54,7 @@
v142
true
Unicode
+ Dynamic
@@ -162,14 +166,17 @@
+
+
+
Create
Create
@@ -179,6 +186,9 @@
+
+
+
diff --git a/PluginDemo/PluginDemo.vcxproj.filters b/PluginDemo/PluginDemo.vcxproj.filters
index ff4dcdb8a..e7d435353 100644
--- a/PluginDemo/PluginDemo.vcxproj.filters
+++ b/PluginDemo/PluginDemo.vcxproj.filters
@@ -36,6 +36,12 @@
头文件
+
+ 头文件
+
+
+ 头文件
+
@@ -53,5 +59,13 @@
源文件
+
+ 源文件
+
+
+
+
+ 资源文件
+
\ No newline at end of file
diff --git a/PluginDemo/dllmain.cpp b/PluginDemo/dllmain.cpp
index ae0709bc5..dfd0cf45c 100644
--- a/PluginDemo/dllmain.cpp
+++ b/PluginDemo/dllmain.cpp
@@ -4,26 +4,28 @@
#include "PluginSystemTime.h"
#include "PluginDemo.h"
#include "DataManager.h"
+#include "OptionsDlg.h"
-
-BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
-{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
+//BOOL APIENTRY DllMain( HMODULE hModule,
+// DWORD ul_reason_for_call,
+// LPVOID lpReserved
+// )
+//{
+// switch (ul_reason_for_call)
+// {
+// case DLL_PROCESS_ATTACH:
+// case DLL_THREAD_ATTACH:
+// case DLL_THREAD_DETACH:
+// case DLL_PROCESS_DETACH:
+// break;
+// }
+// return TRUE;
+//}
IPluginItem* TMPluginCreateInstance(int index)
{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
switch (index)
{
case 0:
@@ -38,6 +40,7 @@ IPluginItem* TMPluginCreateInstance(int index)
void TMPluginInfoRequired()
{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
//获取时间和日期
SYSTEMTIME system_time;
GetSystemTime(&system_time);
@@ -47,3 +50,10 @@ void TMPluginInfoRequired()
swprintf_s(buff, L"%.2d:%.2d:%.2d", system_time.wHour, system_time.wMinute, system_time.wSecond);
CDataManager::Instance().m_cur_time = buff;
}
+
+void TMPluginOptions()
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ COptionsDlg dlg;
+ dlg.DoModal();
+}
diff --git a/PluginDemo/framework.h b/PluginDemo/framework.h
index 80cbbc9b0..b09f35a4b 100644
--- a/PluginDemo/framework.h
+++ b/PluginDemo/framework.h
@@ -1,5 +1,21 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
-// Windows 头文件
-#include
+//// Windows 头文件
+//#include
+
+#include
+
+#include // MFC 核心组件和标准组件
+#include // MFC 扩展
+#include // MFC 自动化类
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
diff --git a/PluginDemo/pch.h b/PluginDemo/pch.h
index 966092717..370adca7f 100644
--- a/PluginDemo/pch.h
+++ b/PluginDemo/pch.h
@@ -10,4 +10,6 @@
// 添加要在此处预编译的标头
#include "framework.h"
+#include "resource.h"
+
#endif //PCH_H
diff --git a/PluginDemo/resource.h b/PluginDemo/resource.h
new file mode 100644
index 000000000..4af258260
--- /dev/null
+++ b/PluginDemo/resource.h
@@ -0,0 +1,17 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ 生成的包含文件。
+// 供 PluginDemo.rc 使用
+//
+#define IDD_DIALOG1 101
+#define IDD_OPTIONS_DIALOG 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/TrafficMonitor/BaseDialog.cpp b/TrafficMonitor/BaseDialog.cpp
index 98dd236cb..0e923f017 100644
--- a/TrafficMonitor/BaseDialog.cpp
+++ b/TrafficMonitor/BaseDialog.cpp
@@ -44,6 +44,13 @@ void CBaseDialog::SaveConfig() const
ini.Save();
}
+void CBaseDialog::EnableDlgCtrl(UINT id, bool enable)
+{
+ CWnd* pWnd = GetDlgItem(id);
+ if (pWnd != nullptr)
+ pWnd->EnableWindow(enable);
+}
+
void CBaseDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
diff --git a/TrafficMonitor/BaseDialog.h b/TrafficMonitor/BaseDialog.h
index 4136f48d5..6231e7dce 100644
--- a/TrafficMonitor/BaseDialog.h
+++ b/TrafficMonitor/BaseDialog.h
@@ -30,6 +30,7 @@ class CBaseDialog : public CDialog
protected:
virtual CString GetDialogName() const = 0;
+ void EnableDlgCtrl(UINT id, bool enable);
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
diff --git a/TrafficMonitor/GeneralSettingsDlg.cpp b/TrafficMonitor/GeneralSettingsDlg.cpp
index 8840f2932..f9806edf8 100644
--- a/TrafficMonitor/GeneralSettingsDlg.cpp
+++ b/TrafficMonitor/GeneralSettingsDlg.cpp
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "TrafficMonitor.h"
#include "GeneralSettingsDlg.h"
-#include "afxdialogex.h"
+#include "PluginManagerDlg.h"
// CGeneralSettingsDlg dialog
@@ -89,6 +89,7 @@ void CGeneralSettingsDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_MBD_TEMP_TIP_EDIT, m_mbd_temp_tip_edit);
DDX_Control(pDX, IDC_SELECT_HARD_DISK_COMBO, m_hard_disk_combo);
DDX_Control(pDX, IDC_SELECT_CPU_COMBO, m_select_cpu_combo);
+ DDX_Control(pDX, IDC_PLUGIN_MANAGE_BUTTON, m_plugin_manager_btn);
}
void CGeneralSettingsDlg::SetControlEnable()
@@ -133,6 +134,7 @@ BEGIN_MESSAGE_MAP(CGeneralSettingsDlg, CTabDlg)
ON_BN_CLICKED(IDC_HDD_CHECK, &CGeneralSettingsDlg::OnBnClickedHddCheck)
ON_BN_CLICKED(IDC_MBD_CHECK, &CGeneralSettingsDlg::OnBnClickedMbdCheck)
ON_CBN_SELCHANGE(IDC_SELECT_CPU_COMBO, &CGeneralSettingsDlg::OnCbnSelchangeSelectCpuCombo)
+ ON_BN_CLICKED(IDC_PLUGIN_MANAGE_BUTTON, &CGeneralSettingsDlg::OnBnClickedPluginManageButton)
END_MESSAGE_MAP()
@@ -269,6 +271,8 @@ BOOL CGeneralSettingsDlg::OnInitDialog()
EnableDlgCtrl(IDC_SELECT_CPU_COMBO, false);
#endif
+ m_plugin_manager_btn.SetIcon(theApp.GetMenuIcon(IDI_PLUGINS));
+
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
@@ -610,3 +614,11 @@ void CGeneralSettingsDlg::OnCbnSelchangeSelectCpuCombo()
m_select_cpu_combo.GetWindowText(cpu_core_name);
m_data.cpu_core_name = cpu_core_name.GetString();
}
+
+
+void CGeneralSettingsDlg::OnBnClickedPluginManageButton()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ CPluginManagerDlg dlg;
+ dlg.DoModal();
+}
diff --git a/TrafficMonitor/GeneralSettingsDlg.h b/TrafficMonitor/GeneralSettingsDlg.h
index d0363e044..e16afd2c0 100644
--- a/TrafficMonitor/GeneralSettingsDlg.h
+++ b/TrafficMonitor/GeneralSettingsDlg.h
@@ -93,4 +93,6 @@ class CGeneralSettingsDlg : public CTabDlg
afx_msg void OnBnClickedHddCheck();
afx_msg void OnBnClickedMbdCheck();
afx_msg void OnCbnSelchangeSelectCpuCombo();
+ afx_msg void OnBnClickedPluginManageButton();
+ CButton m_plugin_manager_btn;
};
diff --git a/TrafficMonitor/PluginManager.cpp b/TrafficMonitor/PluginManager.cpp
index 90ab1110c..6956fae9b 100644
--- a/TrafficMonitor/PluginManager.cpp
+++ b/TrafficMonitor/PluginManager.cpp
@@ -37,6 +37,7 @@ void CPluginManager::LoadPlugins()
plugin_info.error_code = GetLastError();
continue;
}
+ plugin_info.TMPluginOptions = (pfTMPluginOptions)::GetProcAddress(plugin_info.plugin_module, "TMPluginOptions");
int index = 0;
while (true)
{
diff --git a/TrafficMonitor/PluginManager.h b/TrafficMonitor/PluginManager.h
index df116e96f..ecdc149f2 100644
--- a/TrafficMonitor/PluginManager.h
+++ b/TrafficMonitor/PluginManager.h
@@ -4,6 +4,7 @@
typedef IPluginItem* (*pfTMPluginCreateInstance)(int);
typedef void (*pfTMPluginInfoRequired)();
+typedef void (*pfTMPluginOptions)();
//用于加载和管理插件
class CPluginManager
@@ -26,6 +27,7 @@ class CPluginManager
PluginState state{}; //插件的状态
DWORD error_code{}; //错误代码(GetLastError的返回值)
pfTMPluginInfoRequired MPluginInfoRequired{}; //模块中MPluginInfoRequired函数的指针
+ pfTMPluginOptions TMPluginOptions{}; //模块中TMPluginOptions函数的指针
};
CPluginManager();
diff --git a/TrafficMonitor/PluginManagerDlg.cpp b/TrafficMonitor/PluginManagerDlg.cpp
new file mode 100644
index 000000000..57bd14a92
--- /dev/null
+++ b/TrafficMonitor/PluginManagerDlg.cpp
@@ -0,0 +1,127 @@
+// PluginManagerDlg.cpp: 实现文件
+//
+
+#include "stdafx.h"
+#include "TrafficMonitor.h"
+#include "PluginManagerDlg.h"
+#include "FilePathHelper.h"
+
+
+// CPluginManagerDlg 对话框
+
+IMPLEMENT_DYNAMIC(CPluginManagerDlg, CBaseDialog)
+
+CPluginManagerDlg::CPluginManagerDlg(CWnd* pParent /*=nullptr*/)
+ : CBaseDialog(IDD_PLUGIN_MANAGER_DIALOG, pParent)
+{
+
+}
+
+CPluginManagerDlg::~CPluginManagerDlg()
+{
+}
+
+void CPluginManagerDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CBaseDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list_ctrl);
+}
+
+void CPluginManagerDlg::EnableControl()
+{
+ bool select_enable{ m_item_selected >= 0 && m_item_selected < m_list_ctrl.GetItemCount() };
+ EnableDlgCtrl(IDC_OPTINS_BUTTON, select_enable);
+}
+
+CString CPluginManagerDlg::GetDialogName() const
+{
+ return _T("PluginManagerDlg");
+}
+
+
+BEGIN_MESSAGE_MAP(CPluginManagerDlg, CBaseDialog)
+ ON_NOTIFY(NM_RCLICK, IDC_LIST1, &CPluginManagerDlg::OnNMRClickList1)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, &CPluginManagerDlg::OnNMClickList1)
+ ON_BN_CLICKED(IDC_OPTINS_BUTTON, &CPluginManagerDlg::OnBnClickedOptinsButton)
+END_MESSAGE_MAP()
+
+
+// CPluginManagerDlg 消息处理程序
+
+
+BOOL CPluginManagerDlg::OnInitDialog()
+{
+ CBaseDialog::OnInitDialog();
+
+ // TODO: 在此添加额外的初始化
+ SetIcon(theApp.GetMenuIcon(IDI_PLUGINS), FALSE);
+
+ //初始化列表控件
+ CRect rect;
+ m_list_ctrl.GetClientRect(rect);
+ m_list_ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
+ int width0, width1;
+ width0 = rect.Width() / 3;
+ width1 = rect.Width() - width0 - theApp.DPI(20) - 1;
+ m_list_ctrl.InsertColumn(0, CCommon::LoadText(IDS_FILE_NAME), LVCFMT_LEFT, width0);
+ m_list_ctrl.InsertColumn(1, CCommon::LoadText(IDS_STATUS), LVCFMT_LEFT, width1);
+
+ //向列表中插入行
+ for (const auto& plugin : theApp.m_plugins.GetPlugins())
+ {
+ std::wstring file_name = CFilePathHelper(plugin.file_path).GetFileName();
+ CString status;
+ switch (plugin.state)
+ {
+ case CPluginManager::PluginState::PS_SUCCEED:
+ status = _T("加载成功");
+ break;
+ case CPluginManager::PluginState::PS_MUDULE_LOAD_FAILED:
+ status.Format(_T("插件模块加载失败,故障代码:%d"), plugin.error_code);
+ break;
+ case CPluginManager::PluginState::PS_FUNCTION_GET_FAILED:
+ status.Format(_T("函数获取失败,故障代码:%d"), plugin.error_code);
+ break;
+ }
+ int index = m_list_ctrl.GetItemCount();
+ m_list_ctrl.InsertItem(index, file_name.c_str());
+ m_list_ctrl.SetItemText(index, 1, status);
+ }
+
+ EnableControl();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 异常: OCX 属性页应返回 FALSE
+}
+
+
+void CPluginManagerDlg::OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);
+ // TODO: 在此添加控件通知处理程序代码
+ m_item_selected = pNMItemActivate->iItem;
+ EnableControl();
+ *pResult = 0;
+}
+
+
+void CPluginManagerDlg::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR);
+ // TODO: 在此添加控件通知处理程序代码
+ m_item_selected = pNMItemActivate->iItem;
+ EnableControl();
+ *pResult = 0;
+}
+
+
+void CPluginManagerDlg::OnBnClickedOptinsButton()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ if (m_item_selected >= 0 && m_item_selected < static_cast(theApp.m_plugins.GetPlugins().size()))
+ {
+ auto plugin = theApp.m_plugins.GetPlugins()[m_item_selected];
+ if (plugin.TMPluginOptions != nullptr)
+ plugin.TMPluginOptions();
+ }
+}
diff --git a/TrafficMonitor/PluginManagerDlg.h b/TrafficMonitor/PluginManagerDlg.h
new file mode 100644
index 000000000..30e383ae4
--- /dev/null
+++ b/TrafficMonitor/PluginManagerDlg.h
@@ -0,0 +1,36 @@
+#pragma once
+#include "BaseDialog.h"
+
+// CPluginManagerDlg 对话框
+
+class CPluginManagerDlg : public CBaseDialog
+{
+ DECLARE_DYNAMIC(CPluginManagerDlg)
+
+public:
+ CPluginManagerDlg(CWnd* pParent = nullptr); // 标准构造函数
+ virtual ~CPluginManagerDlg();
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_PLUGIN_MANAGER_DIALOG };
+#endif
+
+private:
+ CListCtrl m_list_ctrl;
+ int m_item_selected{ -1 };
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+ void EnableControl();
+
+ DECLARE_MESSAGE_MAP()
+
+ // 通过 CBaseDialog 继承
+ virtual CString GetDialogName() const override;
+public:
+ virtual BOOL OnInitDialog();
+ afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedOptinsButton();
+};
diff --git a/TrafficMonitor/Test.cpp b/TrafficMonitor/Test.cpp
index c55607033..ebf64f8ad 100644
--- a/TrafficMonitor/Test.cpp
+++ b/TrafficMonitor/Test.cpp
@@ -2,6 +2,7 @@
#include "Test.h"
#include "Common.h"
#include "SkinFile.h"
+#include "TrafficMonitor.h"
CTest::CTest()
{
@@ -19,6 +20,11 @@ void CTest::Test()
//TestCrash();
}
+void CTest::TestCommand()
+{
+ TestPlugin();
+}
+
void CTest::TestHttpQequest()
{
wstring result;
@@ -56,3 +62,11 @@ void CTest::TestCrash()
printf("%d", a);
}
+
+void CTest::TestPlugin()
+{
+ if (!theApp.m_plugins.GetPlugins().empty())
+ {
+ theApp.m_plugins.GetPlugins()[0].TMPluginOptions();
+ }
+}
diff --git a/TrafficMonitor/Test.h b/TrafficMonitor/Test.h
index 0b2406464..2252cb266 100644
--- a/TrafficMonitor/Test.h
+++ b/TrafficMonitor/Test.h
@@ -6,10 +6,12 @@ class CTest
~CTest();
static void Test();
+ static void TestCommand();
private:
static void TestHttpQequest();
static void TestGetLicense();
static void TestSkin();
static void TestCrash();
+ static void TestPlugin();
};
diff --git a/TrafficMonitor/TrafficMonitor.cpp b/TrafficMonitor/TrafficMonitor.cpp
index f14cc11a4..1e1c35ac7 100644
--- a/TrafficMonitor/TrafficMonitor.cpp
+++ b/TrafficMonitor/TrafficMonitor.cpp
@@ -730,6 +730,7 @@ void CTrafficMonitorApp::InitMenuResourse()
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_CHANGE_SKIN, FALSE, GetMenuIcon(IDI_SKIN));
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_CHANGE_NOTIFY_ICON, FALSE, GetMenuIcon(IDI_NOTIFY));
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_TRAFFIC_HISTORY, FALSE, GetMenuIcon(IDI_STATISTICS));
+ CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_PLUGIN_MANAGE, FALSE, GetMenuIcon(IDI_PLUGINS));
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_OPTIONS, FALSE, GetMenuIcon(IDI_SETTINGS));
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_HELP, FALSE, GetMenuIcon(IDI_HELP));
CMenuIcon::AddIconToMenuItem(m_main_menu.GetSafeHmenu(), ID_APP_ABOUT, FALSE, GetMenuIcon(IDR_MAINFRAME));
@@ -748,6 +749,9 @@ void CTrafficMonitorApp::InitMenuResourse()
CMenuIcon::AddIconToMenuItem(m_taskbar_menu.GetSafeHmenu(), ID_APP_ABOUT, FALSE, GetMenuIcon(IDR_MAINFRAME));
CMenuIcon::AddIconToMenuItem(m_taskbar_menu.GetSafeHmenu(), ID_APP_EXIT, FALSE, GetMenuIcon(IDI_EXIT));
+#ifdef _DEBUG
+ m_main_menu.GetSubMenu(0)->AppendMenu(MF_BYCOMMAND, ID_CMD_TEST, _T("Test Command"));
+#endif
}
HICON CTrafficMonitorApp::GetMenuIcon(UINT id)
diff --git a/TrafficMonitor/TrafficMonitor.rc b/TrafficMonitor/TrafficMonitor.rc
index d54796cb0..30f798c8d 100644
Binary files a/TrafficMonitor/TrafficMonitor.rc and b/TrafficMonitor/TrafficMonitor.rc differ
diff --git a/TrafficMonitor/TrafficMonitor.vcxproj b/TrafficMonitor/TrafficMonitor.vcxproj
index 304aac840..7b87e1fda 100644
--- a/TrafficMonitor/TrafficMonitor.vcxproj
+++ b/TrafficMonitor/TrafficMonitor.vcxproj
@@ -467,6 +467,7 @@
+
@@ -530,6 +531,7 @@
+
@@ -598,6 +600,7 @@
+
diff --git a/TrafficMonitor/TrafficMonitor.vcxproj.filters b/TrafficMonitor/TrafficMonitor.vcxproj.filters
index fc4da20bd..6a36f0e43 100644
--- a/TrafficMonitor/TrafficMonitor.vcxproj.filters
+++ b/TrafficMonitor/TrafficMonitor.vcxproj.filters
@@ -178,6 +178,9 @@
{f7dd3288-085a-4de2-9f83-d8ba2f3eff47}
+
+ {dbacfb68-1e03-4bcb-a08b-e87ba558985f}
+
@@ -380,6 +383,9 @@
源文件和头文件\公共的类\PluginManager
+
+ 源文件和头文件\对话框类\PluginManagerDlg
+
@@ -559,6 +565,9 @@
源文件和头文件\公共的类\PluginManager
+
+ 源文件和头文件\对话框类\PluginManagerDlg
+
@@ -666,5 +675,8 @@
资源文件
+
+ 资源文件
+
\ No newline at end of file
diff --git a/TrafficMonitor/TrafficMonitorDlg.cpp b/TrafficMonitor/TrafficMonitorDlg.cpp
index 44206460d..1391c6e21 100644
--- a/TrafficMonitor/TrafficMonitorDlg.cpp
+++ b/TrafficMonitor/TrafficMonitorDlg.cpp
@@ -6,6 +6,8 @@
#include "TrafficMonitor.h"
#include "TrafficMonitorDlg.h"
#include "afxdialogex.h"
+#include "Test.h"
+#include "PluginManagerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -108,6 +110,7 @@ BEGIN_MESSAGE_MAP(CTrafficMonitorDlg, CDialog)
ON_MESSAGE(WM_MONITOR_INFO_UPDATED, &CTrafficMonitorDlg::OnMonitorInfoUpdated)
ON_MESSAGE(WM_DISPLAYCHANGE, &CTrafficMonitorDlg::OnDisplaychange)
ON_WM_EXITSIZEMOVE()
+ ON_COMMAND(ID_PLUGIN_MANAGE, &CTrafficMonitorDlg::OnPluginManage)
END_MESSAGE_MAP()
@@ -1826,6 +1829,12 @@ BOOL CTrafficMonitorDlg::OnCommand(WPARAM wParam, LPARAM lParam)
theApp.SaveConfig();
m_connection_change_flag = true;
}
+#ifdef DEBUG
+ if (uMsg == ID_CMD_TEST)
+ {
+ CTest::TestCommand();
+ }
+#endif // DEBUG
return CDialog::OnCommand(wParam, lParam);
}
@@ -2581,3 +2590,11 @@ void CTrafficMonitorDlg::OnExitSizeMove()
CDialog::OnExitSizeMove();
}
+
+
+void CTrafficMonitorDlg::OnPluginManage()
+{
+ // TODO: 在此添加命令处理程序代码
+ CPluginManagerDlg dlg;
+ dlg.DoModal();
+}
diff --git a/TrafficMonitor/TrafficMonitorDlg.h b/TrafficMonitor/TrafficMonitorDlg.h
index 0bd582fbe..878264c14 100644
--- a/TrafficMonitor/TrafficMonitorDlg.h
+++ b/TrafficMonitor/TrafficMonitorDlg.h
@@ -254,4 +254,5 @@ class CTrafficMonitorDlg : public CDialog
afx_msg LRESULT OnDisplaychange(WPARAM wParam, LPARAM lParam);
public:
afx_msg void OnExitSizeMove();
+ afx_msg void OnPluginManage();
};
diff --git a/TrafficMonitor/res/menu_icon/plugins.ico b/TrafficMonitor/res/menu_icon/plugins.ico
new file mode 100644
index 000000000..2be3cc1e4
Binary files /dev/null and b/TrafficMonitor/res/menu_icon/plugins.ico differ
diff --git a/TrafficMonitor/resource.h b/TrafficMonitor/resource.h
index 0c2c49177..347120cd6 100644
--- a/TrafficMonitor/resource.h
+++ b/TrafficMonitor/resource.h
@@ -232,8 +232,10 @@
#define IDD_SELECT_ORDER_DIALOG 330
#define IDS_COLOR 331
#define IDS_COLOR_LABEL 332
+#define IDD_PLUGIN_MANAGER_DIALOG 332
#define IDS_COLOR_VALUE 333
#define IDS_GPU_USAGE 334
+#define IDI_PLUGINS 334
#define IDS_IF_OPER_STATUS_UP 335
#define IDS_IF_OPER_STATUS_DOWN 336
#define IDS_IF_OPER_STATUS_DORMANT 337
@@ -247,6 +249,8 @@
#define IDS_HARDWARE_MONITOR_WARNING 345
#define IDS_HARDWARE_MONITOR_WARNING2 346
#define IDS_HDD_USAGE 347
+#define IDS_FILE_NAME 348
+#define IDS_STATUS 349
#define IDC_STATIC_INFO 1001
#define IDC_STATIC1 1002
#define IDC_STATIC_DOWN 1002
@@ -434,6 +438,8 @@
#define IDC_MOVE_UP_BUTTON 1136
#define IDC_MOVE_DOWN_BUTTON 1137
#define IDC_SET_ORDER_BUTTON 1137
+#define IDC_OPTINS_BUTTON 1139
+#define IDC_PLUGIN_MANAGE_BUTTON 1140
#define ID_32771 32771
#define ID_NETWORK_INFO 32772
#define ID_32773 32773
@@ -530,7 +536,7 @@
#define ID_FIRST_DAY_OF_WEEK_MONDAY 32866
#define ID_CALENDAR_JUMP_TO_TODAY 32867
#define ID_FREQUENTY_ASKED_QUESTIONS 32868
-#define ID_32869 32869
+#define ID_CMD_TEST 32869
#define ID_SHOW_UP_SPEED 32870
#define ID_SHOW_DOWN_SPEED 32871
#define ID_SHOW_CPU_USAGE 32872
@@ -543,16 +549,18 @@
#define ID_SHOW_HDD 32879
#define ID_UPDATE_LOG 32880
#define ID_HELP_32881 32881
+#define ID_32882 32882
+#define ID_PLUGIN_MANAGE 32883
#define ID_SELETE_CONNECTION 33000
#define ID_SELECT_ALL_CONNECTION 33001
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 332
-#define _APS_NEXT_COMMAND_VALUE 32882
-#define _APS_NEXT_CONTROL_VALUE 1139
+#define _APS_NEXT_RESOURCE_VALUE 335
+#define _APS_NEXT_COMMAND_VALUE 32884
+#define _APS_NEXT_CONTROL_VALUE 1141
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif