Beispiel #1
0
        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);
            if (message.Msg == 0x84)    // WM_NCHITTEST
            {
                var cursor = this.PointToClient(Cursor.Position);

                if (TopLeftGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRightGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeftGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRightGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (TopGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (LeftGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (RightGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (BottomGrip.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
        private int HitTestFrame(Point point)
        {
            int result = 0;

            if (TopLeftGrip.Contains(point))
            {
                result = WM.HTTOPLEFT;
            }
            else if (TopRightGrip.Contains(point))
            {
                result = WM.HTTOPRIGHT;
            }
            else if (BottomLeftGrip.Contains(point))
            {
                result = WM.HTBOTTOMLEFT;
            }
            else if (BottomRightGrip.Contains(point))
            {
                result = WM.HTBOTTOMRIGHT;
            }
            else if (TopLine.Contains(point) || TopGrip.Contains(point))
            {
                result = WM.HTTOP;
            }
            else if (LeftLine.Contains(point) || LeftGrip.Contains(point))
            {
                result = WM.HTLEFT;
            }
            else if (RightLine.Contains(point) || RightGrip.Contains(point))
            {
                result = WM.HTRIGHT;
            }
            else if (BottomLine.Contains(point) || (BottomGrip.Contains(point)))
            {
                result = WM.HTBOTTOM;
            }

            return(result);
        }