Fix remote desktop cursor cross-contamination across dialogs
The view-mode "forbidden" cursor was applied with SetClassLongPtr(GCLP_HCURSOR), which mutates the cursor for the whole window class instead of the single dialog instance. Opening a second remote-desktop dialog without remote control overwrote that shared class cursor with IDC_NO, so the already-controlled dialog also began showing the forbidden icon even though it remained operable. Move the view-mode cursor decision into OnSetCursor, which Windows routes per window, and remove the now-unused class-cursor assignments. Remote-control mode and the remote cursor-shape path are left unchanged. Also drop the dead m_hRemoteCursor member and the leftover GetIconInfo block (which leaked hbmMask/hbmColor in ScreenSpyDlg), plus the now-unreferenced m_bMouseTracking flag. Co-Authored-By: deepseek-v4-pro
This commit is contained in:
@@ -843,13 +843,9 @@ BOOL CScreenSpyDlg::OnInitDialog()
|
||||
m_ClientCursorPos.y = 0;
|
||||
m_bCursorIndex = 0;
|
||||
|
||||
m_hRemoteCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
ICONINFO CursorInfo;
|
||||
::GetIconInfo(m_hRemoteCursor, &CursorInfo);
|
||||
SysMenu->CheckMenuItem(IDM_CONTROL, m_bIsCtrl ? MF_CHECKED : MF_UNCHECKED);
|
||||
SysMenu->CheckMenuItem(IDM_ADAPTIVE_SIZE, m_bAdaptiveSize ? MF_CHECKED : MF_UNCHECKED);
|
||||
SysMenu->CheckMenuItem(IDM_TRACE_CURSOR, m_bIsTraceCursor ? MF_CHECKED : MF_UNCHECKED);
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
ShowScrollBar(SB_BOTH, !m_bAdaptiveSize);
|
||||
|
||||
// 设置合理的"正常"窗口大小,显示在主程序所在的显示器上
|
||||
@@ -1990,7 +1986,23 @@ void CScreenSpyDlg::OnPaint()
|
||||
|
||||
BOOL CScreenSpyDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
||||
{
|
||||
if ((m_bIsCtrl && m_Settings.RemoteCursor) && nHitTest == HTCLIENT) {
|
||||
// 查看模式(未开启远程控制):客户区显示禁止图标;标题栏及系统按钮保持正常箭头,
|
||||
// 便于拖动窗口或通过标题栏右键菜单开启远程控制。
|
||||
// 这里按窗口自身状态判断,避免用窗口类光标(GCLP_HCURSOR)时被同类的其他对话框实例
|
||||
// 共享串扰——打开第二个未控制的对话框后,第一个已控制的对话框也被误显示成禁止图标。
|
||||
if (!m_bIsCtrl && nHitTest == HTCLIENT) {
|
||||
::SetCursor(LoadCursor(NULL, IDC_NO));
|
||||
return TRUE;
|
||||
}
|
||||
if (!m_bIsCtrl &&
|
||||
(nHitTest == HTCAPTION || nHitTest == HTSYSMENU || nHitTest == HTMENU ||
|
||||
nHitTest == HTCLOSE || nHitTest == HTMINBUTTON || nHitTest == HTMAXBUTTON ||
|
||||
nHitTest == HTHELP)) {
|
||||
::SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||
return TRUE;
|
||||
}
|
||||
// 控制模式:保持原有逻辑——显示远程光标时客户区隐藏本地物理光标,否则交父类显示远程形状
|
||||
if (m_bIsCtrl && m_Settings.RemoteCursor && nHitTest == HTCLIENT) {
|
||||
::SetCursor(NULL); // 只要在客户区,始终隐藏系统光标
|
||||
return TRUE; // 告诉 Windows 我们处理过了
|
||||
}
|
||||
@@ -2084,7 +2096,6 @@ void CScreenSpyDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||
}
|
||||
SysMenu->CheckMenuItem(IDM_CONTROL, m_bIsCtrl ? MF_CHECKED : MF_UNCHECKED);
|
||||
SysMenu->CheckMenuItem(IDM_TRACE_CURSOR, m_bIsTraceCursor ? MF_CHECKED : MF_UNCHECKED);
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
// 控制模式:禁用本地 IME;查看模式:启用本地 IME
|
||||
ImmAssociateContext(m_hWnd, m_bIsCtrl ? NULL : m_hOldIMC);
|
||||
break;
|
||||
@@ -3473,9 +3484,6 @@ void CScreenSpyDlg::OnMouseMove(UINT nFlags, CPoint point)
|
||||
// 关键:在控制模式下,强制设置光标为空,隐藏本地物理箭头
|
||||
::SetCursor(NULL);
|
||||
}
|
||||
} else if (!m_bMouseTracking) {
|
||||
m_bMouseTracking = true;
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
}
|
||||
|
||||
__super::OnMouseMove(nFlags, point);
|
||||
@@ -3484,9 +3492,6 @@ void CScreenSpyDlg::OnMouseMove(UINT nFlags, CPoint point)
|
||||
void CScreenSpyDlg::OnMouseLeave()
|
||||
{
|
||||
CWnd::OnMouseLeave();
|
||||
|
||||
m_bMouseTracking = false;
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
}
|
||||
|
||||
void CScreenSpyDlg::OnKillFocus(CWnd* pNewWnd)
|
||||
@@ -3566,7 +3571,6 @@ void CScreenSpyDlg::UpdateCtrlStatus(BOOL ctrl)
|
||||
Invalidate(FALSE);
|
||||
}
|
||||
}
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
// 控制模式:禁用本地 IME;查看模式:启用本地 IME
|
||||
ImmAssociateContext(m_hWnd, m_bIsCtrl ? NULL : m_hOldIMC);
|
||||
CMenu* SysMenu = GetSystemMenu(FALSE);
|
||||
|
||||
Reference in New Issue
Block a user