private bool OnNcHitTest(ref Message m, bool contentControl) { int x = NativeMethods.LOWORD(m.LParam); int y = NativeMethods.HIWORD(m.LParam); Point clientLocation = PointToClient(new Point(x, y)); GripBounds gripBouns = new GripBounds(contentControl ? content.ClientRectangle : ClientRectangle); IntPtr transparent = new IntPtr(NativeMethods.HTTRANSPARENT); if (resizableTop) { if (resizableLeft && gripBouns.TopLeft.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOPLEFT; return(true); } if (!resizableLeft && gripBouns.TopRight.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOPRIGHT; return(true); } if (gripBouns.Top.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOP; return(true); } } else { if (resizableLeft && gripBouns.BottomLeft.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOMLEFT; return(true); } if (!resizableLeft && gripBouns.BottomRight.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOMRIGHT; return(true); } if (gripBouns.Bottom.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOM; return(true); } } if (resizableLeft && gripBouns.Left.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTLEFT; return(true); } if (!resizableLeft && gripBouns.Right.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTRIGHT; return(true); } return(false); }
private bool OnNcHitTest(ref Message m, bool contentControl) { if (NonInteractive) { m.Result = (IntPtr) NativeMethods.HTTRANSPARENT; return true; } int x = Cursor.Position.X; // NativeMethods.LOWORD(m.LParam); int y = Cursor.Position.Y; // NativeMethods.HIWORD(m.LParam); Point clientLocation = PointToClient(new Point(x, y)); var gripBouns = new GripBounds(contentControl ? Content.ClientRectangle : ClientRectangle); var transparent = new IntPtr(NativeMethods.HTTRANSPARENT); if (_resizableTop) { if (_resizableLeft && gripBouns.TopLeft.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTTOPLEFT; return true; } if (!_resizableLeft && gripBouns.TopRight.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTTOPRIGHT; return true; } if (gripBouns.Top.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTTOP; return true; } } else { if (_resizableLeft && gripBouns.BottomLeft.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTBOTTOMLEFT; return true; } if (!_resizableLeft && gripBouns.BottomRight.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTBOTTOMRIGHT; return true; } if (gripBouns.Bottom.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTBOTTOM; return true; } } if (_resizableLeft && gripBouns.Left.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTLEFT; return true; } if (!_resizableLeft && gripBouns.Right.Contains(clientLocation)) { m.Result = contentControl ? transparent : (IntPtr) NativeMethods.HTRIGHT; return true; } return false; }