Skip to content

Commit 65a9f8a

Browse files
committed
修正开启“在副显示器中显示任务栏窗口”的状态下,当更改系统设置中“在所有显示器中显示任务栏”选项时,任务栏窗口可能会不显示的问题
1 parent e02ecc6 commit 65a9f8a

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

TrafficMonitor/TaskBarDlg.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,15 @@ void CTaskBarDlg::ApplyWindowTransparentColor()
696696
bool CTaskBarDlg::IsTaskbarChanged()
697697
{
698698
bool is_scendary_display;
699-
return m_hTaskbar != FindTaskbarHandle(is_scendary_display);
699+
static HWND last_taskbar_handle{};
700+
HWND taskbar_handle = FindTaskbarHandle(is_scendary_display);
701+
bool changed{ false };
702+
if (last_taskbar_handle != taskbar_handle)
703+
{
704+
changed = true;
705+
last_taskbar_handle = taskbar_handle;
706+
}
707+
return changed;
700708
}
701709

702710
void CTaskBarDlg::WidthChanged()

TrafficMonitor/TrafficMonitorDlg.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,12 +1919,16 @@ void CTrafficMonitorDlg::OnTimer(UINT_PTR nIDEvent)
19191919
{
19201920
++m_taskbar_timer_cnt;
19211921

1922-
if (theApp.m_taskbar_data.show_taskbar_wnd_in_secondary_display && CWindowsSettingHelper::IsTaskbarShowingInAllDisplays())
1922+
if (theApp.m_taskbar_data.show_taskbar_wnd_in_secondary_display)
19231923
{
19241924
if (m_tBarDlg->IsTaskbarChanged())
19251925
{
1926-
CloseTaskBarWnd();
1927-
OpenTaskBarWnd();
1926+
//延迟一段时间后重启任务栏窗口
1927+
KillTimer(RESTART_TASKBAR_TIMER);
1928+
SetTimer(RESTART_TASKBAR_TIMER, 500, [](HWND, UINT, UINT_PTR, DWORD) {
1929+
theApp.m_pMainWnd->SendMessage(WM_REOPEN_TASKBAR_WND);
1930+
::KillTimer(theApp.m_pMainWnd->GetSafeHwnd(), RESTART_TASKBAR_TIMER);
1931+
});
19281932
}
19291933
}
19301934

TrafficMonitor/stdafx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ using std::ofstream;
8686
#define CONNECTION_DETAIL_TIMER 1237
8787
#define MONITOR_TIMER 1238
8888
#define DELETE_NOTIFY_ICON_TIMER 1239 //删除通知区图标的定时器
89+
#define RESTART_TASKBAR_TIMER 1240
8990

9091
#define MAX_INSERT_TO_TASKBAR_CNT 200 //尝试嵌入任务栏的最大次数
9192
#define WARN_INSERT_TO_TASKBAR_CNT 20 //尝试嵌入任务栏的警告次数

0 commit comments

Comments
 (0)