ITrafficMonitor新增GetMainWindowHwnd、GetTaskbarWindowHwnd函数

This commit is contained in:
zhongyang219
2026-07-22 11:19:33 +08:00
parent 24801439b0
commit 430f14d49d
5 changed files with 43 additions and 2 deletions
+5
View File
@@ -1,6 +1,11 @@
#include "stdafx.h"
#include "IDrawCommon.h"
int IDrawCommon::GetAPIVersion()
{
return 0;
}
void IDrawCommon::DrawWindowText(int x, int y, int w, int h, const wchar_t* lpszString, unsigned long color, Alignment align, bool multi_line, unsigned char alpha)
{
CRect rect(POINT(x, y), SIZE(w, h));
+1
View File
@@ -39,6 +39,7 @@ public:
virtual int GetTextWidth(LPCTSTR lpszString) { return 0; }
// 通过 IPluginDrawer 继承
virtual int GetAPIVersion() override;
virtual void DrawWindowText(int x, int y, int w, int h, const wchar_t* lpszString, unsigned long color, Alignment align, bool multi_line, unsigned char alpha) override;
virtual void SetDrawRect(int x, int y, int w, int h) override;
virtual void FillRect(int x, int y, int w, int h, unsigned long color, unsigned char alpha) override;
+12 -2
View File
@@ -1391,7 +1391,7 @@ int CTrafficMonitorApp::ExitInstance()
int CTrafficMonitorApp::GetAPIVersion()
{
return 0;
return 1;
}
const wchar_t* CTrafficMonitorApp::GetVersion()
@@ -1477,7 +1477,7 @@ const wchar_t* CTrafficMonitorApp::GetPluginConfigDir() const
int CTrafficMonitorApp::GetDPI(DPIType type) const
{
CTrafficMonitorDlg* pMainWnd = dynamic_cast<CTrafficMonitorDlg*>(m_pMainWnd);
CTrafficMonitorDlg* pMainWnd = CTrafficMonitorDlg::Instance();
switch (type)
{
case DPI_MAIN_WND:
@@ -1493,6 +1493,16 @@ int CTrafficMonitorApp::GetDPI(DPIType type) const
return 0;
}
void* CTrafficMonitorApp::GetMainWindowHwnd()
{
return m_pMainWnd->GetSafeHwnd();
}
void* CTrafficMonitorApp::GetTaskbarWindowHwnd()
{
return CTrafficMonitorDlg::Instance()->GetTaskbarWindow()->GetSafeHwnd();
}
const wchar_t* CTrafficMonitorApp::GetStringRes(const wchar_t* key, const wchar_t* section)
{
return m_str_table.LoadText(key, section).c_str();
+2
View File
@@ -211,6 +211,8 @@ public:
unsigned short GetLanguageId() const override;
const wchar_t* GetPluginConfigDir() const override;
int GetDPI(DPIType type) const override;
virtual void* GetMainWindowHwnd() override;
virtual void* GetTaskbarWindowHwnd() override;
};
extern CTrafficMonitorApp theApp;
+23
View File
@@ -440,6 +440,23 @@ public:
* @return
*/
virtual const wchar_t* GetStringRes(const wchar_t* key, const wchar_t* section) = 0;
/**
* @brief 获取主窗口的句柄
* @return
*/
virtual void* GetMainWindowHwnd() = 0;
/**
* @brief 获取任务栏窗口的句柄。不显示任务栏窗口时,返回值为空
* @return
*/
virtual void* GetTaskbarWindowHwnd() = 0;
/**
* API Version
* 1 新增GetMainWindowHwnd、GetTaskbarWindowHwnd函数
*/
};
@@ -447,6 +464,12 @@ public:
class IPluginDrawer
{
public:
/**
* @brief 获取此接口的版本。
* @return int
*/
virtual int GetAPIVersion() = 0;
// 拉伸模式
enum StretchMode
{