Пример #1
0
        protected override void OnMouseUp(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)
            {
                // Are we currently in a redocking state?
                if (_redocker != null)
                {
                    // Let the redocker finish off
                    _redocker.OnMouseUp(e);

                    // No longer need the object
                    _redocker = null;
                }

                // Right mouse button can generate a Context event
                if (e.Button == MouseButtons.Right)
                {
                    // Get screen coordinates of the mouse
                    Point pt = this.PointToScreen(new Point(e.X, e.Y));

                    // Box to transfer as parameter
                    OnContext(pt);
                }
            }

            base.OnMouseUp(e);
        }
Пример #2
0
        protected void OnPageDragEnd(object sender, MouseEventArgs e)
        {
            // Are we currently in a redocking state?
            if (_redocker != null)
            {
                // Let the redocker finish off
                bool moved = _redocker.OnMouseUp(e);

                // If the tab was not positioned somewhere else
                if (!moved)
                {
                    // Put back the page that was removed when dragging started
                    RestoreDraggingPage();
                }

                // No longer need the object
                _redocker = null;
            }
        }
Пример #3
0
        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_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);
        }