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.
94 lines
3.3 KiB
C++
94 lines
3.3 KiB
C++
#pragma once
|
|
#include "Resource.h"
|
|
#include "LangManager.h"
|
|
#include "CIconButton.h"
|
|
|
|
class CScreenSpyDlg;
|
|
|
|
class CToolbarDlg : public CDialogLangEx
|
|
{
|
|
DECLARE_DYNAMIC(CToolbarDlg)
|
|
private:
|
|
int m_lastY = 0; // 记录上一次的 Y 坐标
|
|
|
|
public:
|
|
CScreenSpyDlg* m_pParent = nullptr;
|
|
CToolbarDlg(CScreenSpyDlg* pParent = nullptr);
|
|
virtual ~CToolbarDlg();
|
|
|
|
enum { IDD = IDD_TOOLBAR_DLG };
|
|
|
|
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%)
|
|
|
|
// Icon buttons
|
|
CIconButton m_btnExit;
|
|
CIconButton m_btnControl;
|
|
CIconButton m_btnLock;
|
|
CIconButton m_btnPosition;
|
|
CIconButton m_btnOpacity;
|
|
CIconButton m_btnSwitchScreen;
|
|
CIconButton m_btnBlockInput;
|
|
CIconButton m_btnStatusInfo;
|
|
CIconButton m_btnQuality;
|
|
CIconButton m_btnRestoreConsole;
|
|
CIconButton m_btnX; // 切换窗口按钮
|
|
CIconButton m_btnY; // 预留按钮 Y
|
|
CIconButton m_btnZ; // 预留按钮 Z
|
|
CIconButton m_btnScreenshot;
|
|
CIconButton m_btnGetClipboard; // 获取剪贴板
|
|
CIconButton m_btnSetClipboard; // 设置剪贴板
|
|
CIconButton m_btnMinimize;
|
|
CIconButton m_btnClose;
|
|
|
|
bool m_bBlockInput = false; // 远程输入锁定状态
|
|
bool m_bShowStatusInfo = true; // 状态信息窗口显示状态
|
|
|
|
CToolTipCtrl m_tooltip;
|
|
|
|
void SlideIn();
|
|
void SlideOut();
|
|
void CheckMousePosition();
|
|
void UpdatePosition(); // 更新工具栏位置
|
|
void LayoutButtons(); // 重新排列按钮布局
|
|
void LoadSettings(); // 从注册表加载设置
|
|
void SaveSettings(); // 保存设置到注册表
|
|
void ApplyOpacity(); // 应用透明度
|
|
void UpdateButtonIcons(); // 更新状态相关按钮的图标和提示文本
|
|
RECT GetParentMonitorRect(); // 获取父窗口所在显示器的矩形区域
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
public:
|
|
afx_msg void OnBnClickedExitFullscreen();
|
|
afx_msg void OnBnClickedCtrl();
|
|
afx_msg void OnBnClickedMinimize();
|
|
afx_msg void OnBnClickedClose();
|
|
afx_msg void OnBnClickedLock();
|
|
afx_msg void OnBnClickedPosition();
|
|
afx_msg void OnBnClickedOpacity();
|
|
afx_msg void OnBnClickedSwitchScreen();
|
|
afx_msg void OnBnClickedBlockInput();
|
|
afx_msg void OnBnClickedStatusInfo();
|
|
afx_msg void OnBnClickedQuality();
|
|
afx_msg void OnBnClickedRestoreConsole();
|
|
afx_msg void OnBnClickedX(); // 切换窗口响应函数
|
|
afx_msg void OnBnClickedY(); // 预留按钮 Y 响应函数
|
|
afx_msg void OnBnClickedZ(); // 预留按钮 Z 响应函数
|
|
afx_msg void OnBnClickedScreenshot();
|
|
afx_msg void OnBnClickedGetClipboard();
|
|
afx_msg void OnBnClickedSetClipboard();
|
|
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
|
virtual BOOL OnInitDialog();
|
|
};
|