private unsafe IntPtr MouseHookProc(User32.HC nCode, IntPtr wparam, IntPtr lparam) { GC.KeepAlive(this); if (nCode == User32.HC.ACTION) { User32.MOUSEHOOKSTRUCT *mhs = (User32.MOUSEHOOKSTRUCT *)lparam; if (mhs is not null) { switch (unchecked ((User32.WM)(long) wparam)) { case User32.WM.LBUTTONDOWN: case User32.WM.MBUTTONDOWN: case User32.WM.RBUTTONDOWN: case User32.WM.NCLBUTTONDOWN: case User32.WM.NCMBUTTONDOWN: case User32.WM.NCRBUTTONDOWN: case User32.WM.MOUSEACTIVATE: if (ProcessMouseDown(mhs->hWnd, mhs->pt.X, mhs->pt.Y)) { return((IntPtr)1); } break; } } } return(User32.CallNextHookEx(new HandleRef(this, _mouseHookHandle), nCode, wparam, lparam)); }
private unsafe IntPtr MouseHookProc(User32.HC nCode, IntPtr wparam, IntPtr lparam) { if (_isHooked && nCode == User32.HC.ACTION && lparam != IntPtr.Zero) { User32.MOUSEHOOKSTRUCT *mhs = (User32.MOUSEHOOKSTRUCT *)lparam; try { if (ProcessMouseMessage(mhs->hWnd, unchecked ((int)(long)wparam), mhs->pt.X, mhs->pt.Y)) { return((IntPtr)1); } } catch (Exception ex) { _currentAdornerWindow.Capture = false; if (ex != CheckoutException.Canceled) { _currentAdornerWindow._behaviorService.ShowError(ex); } if (ClientUtils.IsCriticalException(ex)) { throw; } } finally { _currentAdornerWindow = null; } } Debug.Assert(_isHooked, "How did we get here when we are disposed?"); return(User32.CallNextHookEx(new HandleRef(this, _mouseHookHandle), nCode, wparam, lparam)); }