fix: Showing the correct cursor status on window
This commit is contained in:
@@ -59,12 +59,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~CCursorInfo()
|
||||
{
|
||||
for (int i = 0; i < MAX_CURSOR_TYPE; ++i)
|
||||
DestroyCursor(m_CursorHandleArray[i]);
|
||||
}
|
||||
|
||||
int getCurrentCursorIndex() const
|
||||
{
|
||||
CURSORINFO ci;
|
||||
@@ -78,18 +72,14 @@ public:
|
||||
if (ci.hCursor == m_CursorHandleArray[i])
|
||||
break;
|
||||
}
|
||||
DestroyCursor(ci.hCursor);
|
||||
|
||||
int nIndex = i == MAX_CURSOR_TYPE ? -1 : i;
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
HCURSOR getCursorHandle( int nIndex )
|
||||
HCURSOR getCursorHandle( int nIndex ) const
|
||||
{
|
||||
if (nIndex >= 0 && nIndex < MAX_CURSOR_TYPE)
|
||||
return m_CursorHandleArray[nIndex];
|
||||
else
|
||||
return NULL;
|
||||
return (nIndex >= 0 && nIndex < MAX_CURSOR_TYPE) ? m_CursorHandleArray[nIndex] : NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ void CHideScreenSpyDlg::OnClose()
|
||||
ShowWindow(SW_HIDE);
|
||||
return;
|
||||
}
|
||||
|
||||
// 恢复鼠标状态
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, IDC_ARROW));
|
||||
CDialogBase::OnClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ CScreenSpyDlg::CScreenSpyDlg(CWnd* Parent, Server* IOCPServer, CONTEXT_OBJECT* C
|
||||
GetSystemDirectory(szFullPath, MAX_PATH);
|
||||
lstrcat(szFullPath, "\\shell32.dll"); //图标
|
||||
m_hIcon = ExtractIcon(THIS_APP->m_hInstance, szFullPath, 17);
|
||||
m_hCursor = LoadCursor(THIS_APP->m_hInstance, MAKEINTRESOURCE(IDC_ARROWS));
|
||||
|
||||
m_bIsFirst = TRUE;
|
||||
m_ulHScrollPos = 0;
|
||||
@@ -124,6 +123,7 @@ BEGIN_MESSAGE_MAP(CScreenSpyDlg, CDialog)
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MOUSEWHEEL()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_MOUSELEAVE()
|
||||
ON_WM_KILLFOCUS()
|
||||
ON_WM_SIZE()
|
||||
END_MESSAGE_MAP()
|
||||
@@ -200,7 +200,8 @@ VOID CScreenSpyDlg::OnClose()
|
||||
ShowWindow(SW_HIDE);
|
||||
return;
|
||||
}
|
||||
|
||||
// 恢复鼠标状态
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, IDC_ARROW));
|
||||
DialogBase::OnClose();
|
||||
}
|
||||
|
||||
@@ -826,9 +827,28 @@ BOOL CScreenSpyDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
||||
|
||||
void CScreenSpyDlg::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
if (!m_bMouseTracking)
|
||||
{
|
||||
// 第一次进入,开始追踪 WM_MOUSELEAVE
|
||||
TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) };
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
tme.hwndTrack = m_hWnd;
|
||||
TrackMouseEvent(&tme);
|
||||
|
||||
m_bMouseTracking = true;
|
||||
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
|
||||
}
|
||||
|
||||
CDialog::OnMouseMove(nFlags, 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)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
ULONG m_ulVScrollPos;
|
||||
VOID DrawTipString(CString strString);
|
||||
|
||||
HICON m_hCursor;
|
||||
POINT m_ClientCursorPos;
|
||||
BYTE m_bCursorIndex;
|
||||
BOOL m_bIsTraceCursor;
|
||||
@@ -95,6 +94,7 @@ public:
|
||||
HCURSOR m_hRemoteCursor = NULL;
|
||||
CRect m_CRect;
|
||||
double m_wZoom=1, m_hZoom=1;
|
||||
bool m_bMouseTracking = false;
|
||||
|
||||
bool Decode(LPBYTE Buffer, int size);
|
||||
void EnterFullScreen();
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseLeave();
|
||||
afx_msg void OnKillFocus(CWnd* pNewWnd);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user