Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case NativeMethods.WM_NCLBUTTONUP:
                this.captionCapture = false;
                if (this.captionDoubleClick)
                {
                    RestoreAllDockWindows();
                    this.captionDoubleClick = false;
                    return;
                }
                break;

            case NativeMethods.WM_NCLBUTTONDBLCLK:
                if (m.WParam.ToInt64() == NativeMethods.HTCAPTION)
                {
                    this.captionDoubleClick = true;
                }
                break;

            case NativeMethods.WM_NCLBUTTONDOWN:
                //Handle NC_LBUTTONDOWN to prevent WM_ENTERSIZEMOVE modal loop
                if (m.WParam.ToInt64() == NativeMethods.HTCAPTION && this.IsInDragArea())
                {
                    this.captionDoubleClick = false;
                    this.captionCapture     = true;
                    captionDragStart        = Control.MousePosition;
                    ControlHelper.BringToFront(m.HWnd, true);
                    return;
                }
                break;

            case NativeMethods.WM_NCMOUSEMOVE:
                if (captionCapture)
                {
                    if (Control.MouseButtons != MouseButtons.Left)
                    {
                        captionCapture = false;
                    }
                    else if (DockHelper.ShouldBeginDrag(Control.MousePosition, this.captionDragStart))
                    {
                        this.dockManager.BeginDrag(this);
                    }
                    return;
                }
                break;

            case NativeMethods.WM_NCHITTEST:
                if (this.dragged)
                {
                    //we are not target of mouse input while being dragged
                    m.Result = new IntPtr(NativeMethods.HTTRANSPARENT);
                    return;
                }
                break;

            case NativeMethods.WM_NCRBUTTONDOWN:
                //prevent right-button down within the non-client area
                if (this.dockManager != null)
                {
                    return;
                }
                break;

            case NativeMethods.WM_NCRBUTTONUP:
                if (this.dockManager == null)
                {
                    break;
                }

                DockWindow activeWindow = this.dockManager.ActiveWindow;
                if (activeWindow == null || activeWindow.FloatingParent != this)
                {
                    break;
                }

                ContextMenuService service = this.DockManager.GetService <ContextMenuService>(ServiceConstants.ContextMenu);
                if (service != null)
                {
                    service.DisplayContextMenu(this.dockManager.ActiveWindow, Control.MousePosition);
                }
                return;
            }

            base.WndProc(ref m);
        }