protected void OnPageDragMove(object sender, MouseEventArgs e) { // Redocker object needs mouse movements if (_redocker != null) { _redocker.OnMouseMove(e); } }
protected override void OnMouseMove(MouseEventArgs e) { // The double click event will cause the control to be destroyed as // the Contents are restored to their alternative positions, so need to // double check the control is not already dead if (!IsDisposed) { // Redocker object needs mouse movements if (_redocker != null) { _redocker.OnMouseMove(e); } } base.OnMouseMove(e); }
protected override void WndProc(ref Message m) { // Want to notice when the window is maximized if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK) { // Redock and kill ourself Restore(); // We do not want to let the base process the message as the // restore might fail due to lack of permission to restore to // old state. In that case we do not want to maximize the window return; } else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN) { if (!_intercept) { // Perform a hit test against our own window to determine // which area the mouse press is over at the moment. uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); // Only want to override the behviour of moving the window via the caption box if (result == HITTEST_CAPTION) { // Remember new state _intercept = true; // Capture the mouse until the mouse us is received this.Capture = true; // Ensure that we gain focus and look active this.Activate(); // Get mouse position to inscreen coordinates Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Find adjustment to bring screen to client coordinates Point topLeft = PointToScreen(new Point(0, 0)); topLeft.Y -= SystemInformation.CaptionHeight; topLeft.X -= SystemInformation.BorderSize.Width; // Begin a redocking activity _redocker = new RedockerContent(this, new Point(mousePos.x - topLeft.X, mousePos.y - topLeft.Y)); return; } } } else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); return; } } else if ((m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN)) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.QuitTrackingMode(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); // Release capture this.Capture = false; // Reset state _intercept = false; return; } } else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); // Release capture this.Capture = false; // Reset state _intercept = false; return; } } else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP)) { // Prevent middle and right mouse buttons from interrupting // the correct operation of left mouse dragging return; } else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN) { if (!_intercept) { // Get screen coordinates of the mouse Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Box to transfer as parameter OnContext(new Point(mousePos.x, mousePos.y)); return; } } base.WndProc(ref m); }