@@ -693,11 +693,10 @@ bool CTaskBarDlg::AdjustWindowPos()
693693 // 靠近“开始”按钮
694694 if (theApp.m_taskbar_data .tbar_wnd_snap )
695695 {
696- HWND m_hStart = ::FindWindowEx (m_hTaskbar, nullptr , L" Start" , NULL );
697- CRect m_rcStart;
698- ::GetWindowRect (m_hStart, m_rcStart);
696+ CRect rcStart;
697+ ::GetWindowRect (m_hStart, rcStart);
699698
700- m_rect.MoveToX (m_rcStart .left - m_rect.Width () - 2 );
699+ m_rect.MoveToX (rcStart .left - m_rect.Width () - 2 );
701700 }
702701 // 靠近最左侧
703702 else
@@ -719,9 +718,21 @@ bool CTaskBarDlg::AdjustWindowPos()
719718 m_rect.MoveToX (m_left_space);
720719 }
721720 }
722- // 注:这里加上(m_rcTaskbar.Height() - m_rcBar.Height())用于修正Windows11 build 22621版本后触屏设备任务栏窗口位置不正确的问题。
723- // 在这种情况下m_rcTaskbar的高度要大于m_rcBar的高度,正常情况下,它们的高度相同
724- m_rect.MoveToY ((m_rcBar.Height () - m_rect.Height ()) / 2 + (m_rcTaskbar.Height () - m_rcBar.Height ()) + DPI (theApp.m_taskbar_data .window_offset_top ));
721+
722+ // 设置任务栏窗口的垂直位置
723+ if (theApp.m_is_windows11_taskbar )
724+ {
725+ CRect rcStart;
726+ ::GetWindowRect (m_hStart, rcStart);
727+ // 注:这里加上(m_rcTaskbar.Height() - rcStart.Height())用于修正Windows11 build 22621版本后触屏设备任务栏窗口位置不正确的问题。
728+ // 在这种情况下m_rcTaskbar的高度要大于m_rcBar的高度,正常情况下,它们的高度相同
729+ // 但是当任务栏上没有任何图标时,m_rcBar的高度会变为0,因此使用rcStart代替
730+ m_rect.MoveToY ((rcStart.Height () - m_rect.Height ()) / 2 + (m_rcTaskbar.Height () - rcStart.Height ()) + DPI (theApp.m_taskbar_data .window_offset_top ));
731+ }
732+ else
733+ {
734+ m_rect.MoveToY ((m_rcBar.Height () - m_rect.Height ()) / 2 + DPI (theApp.m_taskbar_data .window_offset_top ));
735+ }
725736 if (theApp.m_taskbar_data .horizontal_arrange && theApp.m_win_version .IsWindows7 ())
726737 m_rect.MoveToY (m_rect.top + DPI (1 ));
727738 MoveWindow (m_rect);
@@ -1248,6 +1259,15 @@ bool CTaskBarDlg::IsTaskbarCloseToIconEnable(bool taskbar_wnd_on_left)
12481259 );
12491260}
12501261
1262+ std::wstring CTaskBarDlg::GetTaskbarDebugString () const
1263+ {
1264+ std::wstring str = std::format (L" m_rcTaskbar: 左上坐标({},{}) 左下坐标({},{}) 大小({}x{})"
1265+ " \r\n m_rcBar: 左上坐标({},{}) 左下坐标({},{}) 大小({}x{})" ,
1266+ m_rcTaskbar.left , m_rcTaskbar.top , m_rcTaskbar.right , m_rcTaskbar.bottom , m_rcTaskbar.Width (), m_rcTaskbar.Height (),
1267+ m_rcBar.left , m_rcBar.top , m_rcBar.right , m_rcBar.bottom , m_rcBar.Width (), m_rcBar.Height ());
1268+ return str;
1269+ }
1270+
12511271BOOL CTaskBarDlg::OnInitDialog ()
12521272{
12531273 CDialogEx::OnInitDialog ();
@@ -1268,6 +1288,7 @@ BOOL CTaskBarDlg::OnInitDialog()
12681288 m_hMin = ::FindWindowEx (m_hBar, 0 , L" MSTaskSwWClass" , NULL ); // 寻找最小化窗口的句柄
12691289
12701290 m_hNotify = ::FindWindowEx (m_hTaskbar, 0 , L" TrayNotifyWnd" , NULL );
1291+ m_hStart = ::FindWindowEx (m_hTaskbar, nullptr , L" Start" , NULL );
12711292
12721293 // 设置窗口透明色
12731294 ApplyWindowTransparentColor ();
0 commit comments