Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TrafficMonitor/CommonData.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ struct TaskBarSettingData : public PublicSettingData
bool disable_d2d{ false };//是否禁用d2d绘图
DWORD update_layered_window_error_code{0}; // 使用D2D1渲染时,UpdateLayeredWindowIndirect失败的错误代码,会在关闭任务栏窗口时被重置为0
bool enable_colorful_emoji{ true }; //是否显示彩色emoji
bool m_mouse_penetrate{ false }; //任务栏窗口鼠标穿透

bool is_windows_web_experience_detected{ false }; //是否检测到Windows Web Experience小组件安装信息
};
Expand Down
23 changes: 23 additions & 0 deletions TrafficMonitor/TaskBarDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,29 @@ void CTaskBarDlg::ApplyWindowTransparentColor()
{
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
}

//任务栏窗口鼠标穿透
//不能通过WM_NCHITTEST返回HTTRANSPARENT实现:该机制只在同一线程创建的窗口之间传递命中测试,
//而本窗口已被SetParent到资源管理器的任务栏中,下方的窗口都属于其他进程,鼠标消息会被直接丢弃。
//WS_EX_LAYERED|WS_EX_TRANSPARENT组合由系统在命中测试时直接跳过本窗口,可以跨进程穿透到任务栏。
LONG ex_style = GetWindowLong(m_hWnd, GWL_EXSTYLE);
if (theApp.m_taskbar_data.m_mouse_penetrate)
{
if (!(ex_style & WS_EX_LAYERED))
{
//背景不透明(GDI渲染)时窗口没有分层属性,需要补上WS_EX_LAYERED,并将不透明度设为255以保证窗口正常显示
SetWindowLong(m_hWnd, GWL_EXSTYLE, ex_style | WS_EX_LAYERED | WS_EX_TRANSPARENT);
SetLayeredWindowAttributes(0, 255, LWA_ALPHA);
}
else
{
SetWindowLong(m_hWnd, GWL_EXSTYLE, ex_style | WS_EX_TRANSPARENT);
}
}
else
{
SetWindowLong(m_hWnd, GWL_EXSTYLE, ex_style & ~WS_EX_TRANSPARENT);
}
#endif // !COMPILE_FOR_WINXP
}

Expand Down
8 changes: 8 additions & 0 deletions TrafficMonitor/TaskBarSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ BEGIN_MESSAGE_MAP(CTaskBarSettingsDlg, CTabDlg)
ON_CBN_SELCHANGE(IDC_DISPLAY_TO_SHOW_TASKBAR_WND_COMBO, &CTaskBarSettingsDlg::OnCbnSelchangeDisplayToShowTaskbarWndCombo)
ON_BN_CLICKED(IDC_USAGE_GRAPH_FOLLOW_SYSTEM_CHECK, &CTaskBarSettingsDlg::OnBnClickedUsageGraphFollowSystemCheck)
ON_EN_CHANGE(IDC_FONT_SIZE_EDIT1, &CTaskBarSettingsDlg::OnEnChangeFontSizeEdit1)
ON_BN_CLICKED(IDC_TASKBAR_MOUSE_PENETRATE_CHECK, &CTaskBarSettingsDlg::OnBnClickedTaskbarMousePenetrateCheck)
END_MESSAGE_MAP()


Expand Down Expand Up @@ -307,6 +308,7 @@ BOOL CTaskBarSettingsDlg::OnInitDialog()
((CButton*)GetDlgItem(IDC_SHOW_STATUS_BAR_CHECK))->SetCheck(m_data.show_status_bar);
((CButton*)GetDlgItem(IDC_SEPARATE_VALUE_UNIT_CHECK))->SetCheck(m_data.separate_value_unit_with_space);
((CButton*)GetDlgItem(IDC_SHOW_TOOL_TIP_CHK))->SetCheck(m_data.show_tool_tip);
CheckDlgButton(IDC_TASKBAR_MOUSE_PENETRATE_CHECK, m_data.m_mouse_penetrate);

CheckDlgButton(IDC_TASKBAR_WND_IN_SECONDARY_DISPLAY_CHECK, m_data.show_taskbar_wnd_in_secondary_display);

Expand Down Expand Up @@ -990,3 +992,9 @@ void CTaskBarSettingsDlg::OnEnChangeFontSizeEdit1()
{
m_data.font.size = m_font_size_edit.GetValue();
}


void CTaskBarSettingsDlg::OnBnClickedTaskbarMousePenetrateCheck()
{
m_data.m_mouse_penetrate = (IsDlgButtonChecked(IDC_TASKBAR_MOUSE_PENETRATE_CHECK) != FALSE);
}
1 change: 1 addition & 0 deletions TrafficMonitor/TaskBarSettingsDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ class CTaskBarSettingsDlg : public CTabDlg
afx_msg void OnCbnSelchangeDisplayToShowTaskbarWndCombo();
afx_msg void OnBnClickedUsageGraphFollowSystemCheck();
afx_msg void OnEnChangeFontSizeEdit1();
afx_msg void OnBnClickedTaskbarMousePenetrateCheck();
};
9 changes: 7 additions & 2 deletions TrafficMonitor/TrafficMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ void CTrafficMonitorApp::LoadConfig()
else
m_taskbar_data.disable_d2d = true;
m_taskbar_data.enable_colorful_emoji = ini.GetBool(L"task_bar", L"enable_colorful_emoji", true);
// 迁移:如果 mouse_penetrate 键不存在,则继承主窗口的鼠标穿透设置
m_taskbar_data.m_mouse_penetrate = ini.GetBool(L"task_bar", L"mouse_penetrate", m_main_wnd_data.m_mouse_penetrate);

//其他设置
//m_cfg_data.m_show_internet_ip = ini.GetBool(L"connection_details", L"show_internet_ip", false);
Expand Down Expand Up @@ -421,6 +423,7 @@ void CTrafficMonitorApp::SaveConfig()

ini.WriteBool(L"task_bar", L"disable_d2d", m_taskbar_data.disable_d2d);
ini.WriteBool(L"task_bar", L"enable_colorful_emoji", m_taskbar_data.enable_colorful_emoji);
ini.WriteBool(L"task_bar", L"mouse_penetrate", m_taskbar_data.m_mouse_penetrate);

//其他设置
//ini.WriteBool(L"connection_details", L"show_internet_ip", m_cfg_data.m_show_internet_ip);
Expand Down Expand Up @@ -1201,8 +1204,10 @@ void CTrafficMonitorApp::UpdateOpenHardwareMonitorEnableState()

bool CTrafficMonitorApp::IsForceShowNotifyIcon()
{
return ((!m_cfg_data.m_show_task_bar_wnd /*|| m_win_version.IsWindows11OrLater()*/)
&& (m_cfg_data.m_hide_main_window || m_main_wnd_data.m_mouse_penetrate)); //如果没有显示任务栏窗口,且隐藏了主窗口或设置了鼠标穿透,则禁用“显示通知区图标”菜单项
// 任务栏窗口可交互 = 已显示 且 未设置鼠标穿透
bool taskbar_interactive = m_cfg_data.m_show_task_bar_wnd && !m_taskbar_data.m_mouse_penetrate;
return (!taskbar_interactive
&& (m_cfg_data.m_hide_main_window || m_main_wnd_data.m_mouse_penetrate));
}

std::wstring CTrafficMonitorApp::GetPlauginTooltipInfo() const
Expand Down
Binary file modified TrafficMonitor/TrafficMonitor.rc
Binary file not shown.
11 changes: 11 additions & 0 deletions TrafficMonitor/TrafficMonitorDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ void CTrafficMonitorDlg::ApplySettings(COptionsDlg& optionsDlg)
bool is_hardware_monitor_item_changed = (optionsDlg.m_tab3_dlg.m_data.hardware_monitor_item != theApp.m_general_data.hardware_monitor_item);
bool is_always_on_top_changed = (optionsDlg.m_tab1_dlg.m_data.m_always_on_top != theApp.m_main_wnd_data.m_always_on_top);
bool is_mouse_penerate_changed = (optionsDlg.m_tab1_dlg.m_data.m_mouse_penetrate != theApp.m_main_wnd_data.m_mouse_penetrate);
bool is_taskbar_mouse_penetrate_changed = (optionsDlg.m_tab2_dlg.m_data.m_mouse_penetrate != theApp.m_taskbar_data.m_mouse_penetrate);
bool is_alow_out_of_border_changed = (optionsDlg.m_tab1_dlg.m_data.m_alow_out_of_border != theApp.m_main_wnd_data.m_alow_out_of_border);
bool is_show_notify_icon_changed = (optionsDlg.m_tab3_dlg.m_data.show_notify_icon != theApp.m_general_data.show_notify_icon);
bool is_connections_hide_changed = (optionsDlg.m_tab3_dlg.m_data.connections_hide.data() != theApp.m_general_data.connections_hide.data());
Expand Down Expand Up @@ -837,6 +838,16 @@ void CTrafficMonitorDlg::ApplySettings(COptionsDlg& optionsDlg)
}
}

if (is_taskbar_mouse_penetrate_changed)
{
//任务栏鼠标穿透变化后,检查是否需要强制显示通知区图标
if (!theApp.m_general_data.show_notify_icon && theApp.IsForceShowNotifyIcon())
{
AddNotifyIcon();
theApp.m_general_data.show_notify_icon = true;
}
}

if (is_alow_out_of_border_changed)
{
CheckWindowPos();
Expand Down
3 changes: 2 additions & 1 deletion TrafficMonitor/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
#define IDC_MBD_TEMP_TIP_EDIT 1219
#define IDC_AUTO_RUN_METHOD_REGESTRY_RADIO 1220
#define IDC_AUTO_RUN_METHOD_TASK_SCHEDULE_RADIO 1221
#define IDC_TASKBAR_MOUSE_PENETRATE_CHECK 1222
#define ID_32771 32771
#define ID_NETWORK_INFO 32772
#define ID_32773 32773
Expand Down Expand Up @@ -468,7 +469,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 349
#define _APS_NEXT_COMMAND_VALUE 33666
#define _APS_NEXT_CONTROL_VALUE 1221
#define _APS_NEXT_CONTROL_VALUE 1223
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif