Example #1
0
        /// <summary>
        /// Sets the appropriate cursor style for the current mouse position.
        /// </summary>
        private ParentHitTestResult SetCurrentCursor()
        {
            // Get hit test result & act accordingly.
            ParentHitTestResult result = HitTestParentControl();

            if (result != ParentHitTestResult.Null)
            {
                if (result == ParentHitTestResult.TopLeft || result == ParentHitTestResult.BottomRight)
                {
                    Cursor.Current = Cursors.SizeNWSE;
                }
                else if (result == ParentHitTestResult.BottomLeft || result == ParentHitTestResult.TopRight)
                {
                    Cursor.Current = Cursors.SizeNESW;
                }
                else if (result == ParentHitTestResult.Left || result == ParentHitTestResult.Right)
                {
                    Cursor.Current = Cursors.SizeWE;
                }
                else if (result == ParentHitTestResult.Top || result == ParentHitTestResult.Bottom)
                {
                    Cursor.Current = Cursors.SizeNS;
                }
            }
            else
            {
                Cursor.Current = Cursors.Default;
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Moves the window if executed, accepts the windows form that is
        /// to be moved.
        /// </summary>
        /// <param name="handle">The handle to the form, event or control that is to be moved.</param>
        /// <param name="result">Tells us precisely which corner the mouse is at, if any.</param>
        private void ResizeWindow(IntPtr handle, ParentHitTestResult result)
        {
            if (result != ParentHitTestResult.Null)
            {
                // I can't find the documentataion on those variations of the SC_MOVE, I got them by trial + error
                // 000 = Mouse Center Reset
                // 001 = Left
                // 002 = Right
                // 003 = Top
                // 004 = TopLeft
                // 005 = TopRight
                // 006 = Bottom
                // 007 = BottomLeft
                // 008 = BottomRight

                if (result == ParentHitTestResult.Left)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF001, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.Right)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF002, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.Top)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF003, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.TopLeft)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF004, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.TopRight)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF005, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.Bottom)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF006, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.BottomLeft)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF007, IntPtr.Zero);
                }
                if (result == ParentHitTestResult.BottomRight)
                {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr)0xF008, IntPtr.Zero);
                }
            }
            ReleaseCapture();
        }