Example #1
0
        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 (resizableRight && gripBouns.TopLeft.Contains(clientLocation))
                {
                    m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOPLEFT;
                    return(true);
                }
                if (!resizableRight && 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 (resizableRight && gripBouns.BottomLeft.Contains(clientLocation))
                {
                    m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOMLEFT;
                    return(true);
                }
                if (!resizableRight && 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 (resizableRight && gripBouns.Left.Contains(clientLocation))
            {
                m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTLEFT;
                return(true);
            }
            if (!resizableRight && gripBouns.Right.Contains(clientLocation))
            {
                m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTRIGHT;
                return(true);
            }
            return(false);
        }
Example #2
0
        private bool OnNcHitTest(ref Message m)
        {
            Point     location = PointToClient(new Point(NativeMethods.LOWORD(m.LParam), NativeMethods.HIWORD(m.LParam)));
            Rectangle gripRect = Rectangle.Empty;

            if (_canResize && !_changeRegion)
            {
                if (_resizableLeft)
                {
                    gripRect = _resizableTop ? new Rectangle(0, 0, 6, 6) : new Rectangle(0, Height - 6, 6, 6);
                }
                else
                {
                    gripRect = _resizableTop ? new Rectangle(Width - 6, 0, 6, 6) : new Rectangle(Width - 6, Height - 6, 6, 6);
                }
            }

            if (gripRect.Contains(location))
            {
                if (_resizableLeft)
                {
                    if (_resizableTop)
                    {
                        m.Result = (IntPtr)HITTEST.HTTOPLEFT;
                        return(true);
                    }
                    else
                    {
                        m.Result = (IntPtr)HITTEST.HTBOTTOMLEFT;
                        return(true);
                    }
                }
                else
                {
                    if (_resizableTop)
                    {
                        m.Result = (IntPtr)HITTEST.HTTOPRIGHT;
                        return(true);
                    }
                    else
                    {
                        m.Result = (IntPtr)HITTEST.HTBOTTOMRIGHT;
                        return(true);
                    }
                }
            }
            else
            {
                Rectangle rectClient = ClientRectangle;
                if (location.X > rectClient.Right - 3 && location.X <= rectClient.Right && !_resizableLeft)
                {
                    m.Result = (IntPtr)HITTEST.HTRIGHT;
                    return(true);
                }
                else if (location.Y > rectClient.Bottom - 3 && location.Y <= rectClient.Bottom && !_resizableTop)
                {
                    m.Result = (IntPtr)HITTEST.HTBOTTOM;
                    return(true);
                }
                else if (location.X > -1 && location.X < 3 && _resizableLeft)
                {
                    m.Result = (IntPtr)HITTEST.HTLEFT;
                    return(true);
                }
                else if (location.Y > -1 && location.Y < 3 && _resizableTop)
                {
                    m.Result = (IntPtr)HITTEST.HTTOP;
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        private bool OnNcHitTest(ref Message m, bool contentControl)
        {
            int        x          = NativeMethods.LOWORD(m.LParam);
            int        y          = NativeMethods.HIWORD(m.LParam);
            Point      pt         = base.PointToClient(new Point(x, y));
            GripBounds gripBounds = new GripBounds(contentControl ? this.content.ClientRectangle : base.ClientRectangle);
            IntPtr     intPtr     = new IntPtr(-1);
            bool       result;

            if (this.resizableTop)
            {
                if (this.resizableRight && gripBounds.TopLeft.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)13));
                    result   = true;
                    return(result);
                }
                if (!this.resizableRight && gripBounds.TopRight.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)14));
                    result   = true;
                    return(result);
                }
                if (gripBounds.Top.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)12));
                    result   = true;
                    return(result);
                }
            }
            else
            {
                if (this.resizableRight && gripBounds.BottomLeft.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)16));
                    result   = true;
                    return(result);
                }
                if (!this.resizableRight && gripBounds.BottomRight.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)17));
                    result   = true;
                    return(result);
                }
                if (gripBounds.Bottom.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)15));
                    result   = true;
                    return(result);
                }
            }
            if (this.resizableRight && gripBounds.Left.Contains(pt))
            {
                m.Result = (contentControl ? intPtr : ((IntPtr)10));
                result   = true;
            }
            else
            {
                if (!this.resizableRight && gripBounds.Right.Contains(pt))
                {
                    m.Result = (contentControl ? intPtr : ((IntPtr)11));
                    result   = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Example #4
0
		internal static int LOWORD(IntPtr n)
		{
			return NativeMethods.LOWORD((int)((long)n));
		}