Skip to content

Commit

Permalink
任务栏窗口水平偏移选项和垂直偏移选项仅用于Win11
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed Jan 22, 2025
1 parent 30087f6 commit 31fae2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 10 additions & 7 deletions TrafficMonitor/TaskBarDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,12 +719,15 @@ bool CTaskBarDlg::AdjustWindowPos()
}
}
//水平偏移
m_rect.MoveToX(m_rect.left + DPI(theApp.m_taskbar_data.window_offset_left));
//确保水平方向不超出屏幕边界
if (m_rect.left < 0)
m_rect.MoveToX(0);
if (m_rcTaskbar.right > m_rect.Width() && m_rect.right > m_rcTaskbar.right)
m_rect.MoveToX(m_rcTaskbar.right - m_rect.Width());
if (theApp.m_is_windows11_taskbar)
{
m_rect.MoveToX(m_rect.left + DPI(theApp.m_taskbar_data.window_offset_left));
//确保水平方向不超出屏幕边界
if (m_rect.left < 0)
m_rect.MoveToX(0);
if (m_rcTaskbar.right > m_rect.Width() && m_rect.right > m_rcTaskbar.right)
m_rect.MoveToX(m_rcTaskbar.right - m_rect.Width());
}

//设置任务栏窗口的垂直位置
if (theApp.m_is_windows11_taskbar)
Expand All @@ -738,7 +741,7 @@ bool CTaskBarDlg::AdjustWindowPos()
}
else
{
m_rect.MoveToY((m_rcBar.Height() - m_rect.Height()) / 2 + DPI(theApp.m_taskbar_data.window_offset_top));
m_rect.MoveToY((m_rcBar.Height() - m_rect.Height()) / 2);
}
if (theApp.m_taskbar_data.horizontal_arrange && theApp.m_win_version.IsWindows7())
m_rect.MoveToY(m_rect.top + DPI(1));
Expand Down
6 changes: 2 additions & 4 deletions TrafficMonitor/TaskBarSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,10 @@ BOOL CTaskBarSettingsDlg::OnInitDialog()
CTaskBarDlg* taskbar_dlg{ CTrafficMonitorDlg::Instance()->GetTaskbarWindow() };
m_window_offset_top_edit.SetRange(-5, 20);
m_window_offset_top_edit.SetValue(m_data.window_offset_top);
if (taskbar_dlg != nullptr)
m_window_offset_top_edit.EnableWindow(taskbar_dlg->IsTasksbarOnTopOrBottom());
m_window_offset_top_edit.EnableWindow(theApp.m_is_windows11_taskbar);
m_window_offset_left_edit.SetRange(-800, 800);
m_window_offset_left_edit.SetValue(m_data.window_offset_left);
if (taskbar_dlg != nullptr)
m_window_offset_left_edit.EnableWindow(taskbar_dlg->IsTasksbarOnTopOrBottom());
m_window_offset_left_edit.EnableWindow(theApp.m_is_windows11_taskbar);
m_vertical_margin_edit.SetRange(-10, 10);
m_vertical_margin_edit.SetValue(m_data.vertical_margin);
if (taskbar_dlg != nullptr)
Expand Down

0 comments on commit 31fae2c

Please sign in to comment.