Пример #1
0
        protected virtual IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            handled = false;

            switch (msg)
            {
            //VS Does not behave like this, so commented out
            case (int)WindowsMessage.WmActivate:
                if (((int)wParam & 0xFFFF) == 0)
                {
                    //if (lParam == this.GetParentWindowHandle())
                    //{
                    //	Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                    //	handled = true;
                    //}
                }
                break;

            case (int)WindowsMessage.WmExitsizemove:
                UpdatePositionAndSizeOfPanes();

                if (_dragService != null)
                {
                    var mousePosition = this.TransformToDeviceDpi(NativeMethods.GetMousePosition());
                    _dragService.Drop(mousePosition, out var dropFlag);
                    _dragService = null;
                    SetIsDragging(false);

                    if (dropFlag)
                    {
                        InternalClose();
                    }
                }

                break;

            case (int)WindowsMessage.WmMoving:
            {
                UpdateDragPosition();
            }
            break;

            case (int)WindowsMessage.WmLbuttonup:
                //set as handled right button click on title area (after showing context menu)
                if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released)
                {
                    _dragService.Abort();
                    _dragService = null;
                    SetIsDragging(false);
                }
                break;

            case (int)WindowsMessage.WmSyscommand:
                IntPtr wMaximize = new IntPtr((int)Native.Platform.Enums.SystemCommands.ScMaximize);
                IntPtr wRestore  = new IntPtr((int)Native.Platform.Enums.SystemCommands.ScRestore);
                if (wParam == wMaximize || wParam == wRestore)
                {
                    UpdateMaximizedState(wParam == wMaximize);
                }
                break;

            case (int)WindowsMessage.WmNclbuttondblclk:
                if (msg != 24)
                {
                    if (msg == (int)WindowsMessage.WmNclbuttondblclk)
                    {
                        WmNcLButtonDblClk(wParam, ref handled);
                        return(IntPtr.Zero);
                    }
                }
                else
                {
                    WmShowWindow(hwnd, lParam);
                    return(IntPtr.Zero);
                }
                break;
            }
            return(IntPtr.Zero);
        }