Fix: keep the floating toolbar open while its quality menu is up

With the toolbar unpinned, CheckMousePosition() runs from the full-screen
timer every 50ms and slides the bar out once the cursor leaves the edge
band. The quality menu drops from the button's bottom edge, so its first
item already sits past the monTop + m_nHeight + 10 threshold: the bar
retracted the moment the user moved onto the menu, taking the menu with it.

A m_bMenuOpen flag now suspends the retract decision while TrackPopupMenu
is running. The menu's modal loop still dispatches the parent's WM_TIMER,
so without this the bar animates away under it. The flag is set and cleared
around the call, so behaviour is unchanged once the menu closes or is
dismissed with Esc.

Only the quality menu opens a popup, so nothing else needed the flag.

Verified: debug server build, 0 errors, ToolbarDlg.cpp rebuilt. UI not
exercised.
This commit is contained in:
yuanyuanxiang committed 2026-11-07 15:45:48 +01:00
1 parent 6b87a31c6f
commit 49ba0c4850
2 files changed
+17

No files matched your search

+13
View File
@@ -79,6 +79,15 @@ void CToolbarDlg::CheckMousePosition()
return;
}
// 菜单开着时不做缩回判定:菜单会展开到屏幕中间,鼠标跟着离开边缘区域,
// 按下面的逻辑就会 SlideOut,工具栏一藏菜单也就没了。
if (m_bMenuOpen) {
if (!m_bVisible) {
SlideIn();
}
return;
}
CPoint pt;
GetCursorPos(&pt);
@@ -722,7 +731,11 @@ void CToolbarDlg::OnBnClickedQuality()
// 弹出菜单
CRect rc;
m_btnQuality.GetWindowRect(&rc);
// 菜单开着期间禁止自动缩回:TrackPopupMenu 是模态循环,父窗口的 WM_TIMER 照常
// 派发,鼠标移到菜单上就算"离开边缘",工具栏缩回去菜单也跟着消失。
m_bMenuOpen = true;
UINT cmd = menu.TrackPopupMenu(TPM_RETURNCMD | TPM_NONOTIFY, rc.right, rc.top, this);
m_bMenuOpen = false;
if (cmd) {
GetParent()->PostMessage(WM_SYSCOMMAND, cmd, 0);
}
+4
View File
@@ -21,6 +21,10 @@ public:
int m_nHeight = 40;
bool m_bVisible = false;
bool m_bLocked = false; // 是否锁定工具栏
// 弹出菜单期间暂停自动缩回。TrackPopupMenu 是模态循环,父窗口的 WM_TIMER 照常
// 派发,鼠标一离开屏幕边缘 CheckMousePosition 就会 SlideOut,菜单跟着消失,
// 质量等级根本选不了。
bool m_bMenuOpen = false;
int m_nPosition = 0; // 工具栏位置 (0=上, 1=下, 2=左, 3=右)
int m_nOpacityLevel = 0; // 透明度级别 (0=100%, 1=75%, 2=50%)