コード例 #1
0
        private static void RaiseNonClientMouseMessageAsClient(IntPtr hwnd, int msg, IntPtr lparam)
        {
            var point = new Core.Platform.Point
            {
                X = NativeMethods.GetXlParam(lparam.ToInt32()),
                Y = NativeMethods.GetYlParam(lparam.ToInt32())
            };

            NativeMethods.ScreenToClient(hwnd, ref point);
            NativeMethods.SendMessage(hwnd, msg + 513 - 161, new IntPtr(PressedMouseButtons),
                                      NativeMethods.MakeParam(point.X, point.Y));
        }
コード例 #2
0
        private IntPtr WmHcHitTest(IntPtr lparam, ref bool handled)
        {
            if (PresentationSource.FromDependencyObject(this) == null)
            {
                return(new IntPtr(0));
            }
            var point1 = new Point(NativeMethods.GetXlParam(lparam.ToInt32()),
                                   NativeMethods.GetYlParam(lparam.ToInt32()));
            var point2 = PointFromScreen(point1);
            DependencyObject visualHit = null;

            VisualUtilities.HitTestVisibleElements(this,
                                                   target =>
            {
                visualHit = target.VisualHit;
                return(HitTestResultBehavior.Stop);
            }, new PointHitTestParameters(point2));
            var num = 0;

            for (; visualHit != null; visualHit = visualHit.GetVisualOrLogicalParent1())
            {
                var nonClientArea = visualHit as INonClientArea;
                if (nonClientArea == null)
                {
                    continue;
                }
                num = nonClientArea.HitTest(point1);
                if (num != 0)
                {
                    break;
                }
            }
            if (num == 0)
            {
                num = 1;
            }
            handled = true;
            return(new IntPtr(num));
        }
コード例 #3
0
        private Cursor GetCursor(IntPtr lParam)
        {
            var  xlParam = NativeMethods.GetXlParam(lParam.ToInt32());
            var  ylParam = NativeMethods.GetYlParam(lParam.ToInt32());
            RECT lpRect;

            NativeMethods.GetWindowRect(new WindowInteropHelper(this).Handle, out lpRect);

            switch (_direction)
            {
            case Dock.Left:
                if (ylParam - 18 < lpRect.Top)
                {
                    return(Cursors.SizeNWSE);
                }
                return(ylParam + 18 > lpRect.Bottom ? Cursors.SizeNESW : Cursors.SizeWE);

            case Dock.Top:
                if (xlParam - 18 < lpRect.Left)
                {
                    return(Cursors.SizeNWSE);
                }
                return(xlParam + 18 > lpRect.Right ? Cursors.SizeNESW : Cursors.SizeNS);

            case Dock.Right:
                if (ylParam - 18 < lpRect.Top)
                {
                    return(Cursors.SizeNESW);
                }
                return(ylParam + 18 > lpRect.Bottom ? Cursors.SizeNWSE : Cursors.SizeWE);

            default:
                if (xlParam - 18 < lpRect.Left)
                {
                    return(Cursors.SizeNESW);
                }
                return(xlParam + 18 > lpRect.Right ? Cursors.SizeNWSE : Cursors.SizeNS);
            }
        }