Ejemplo n.º 1
0
        private void CalculateRect(IntPtr scrollBarHWnd, bool bHorizontal, out Rectangle bounds, out Rectangle trackRect, out Rectangle topLeftArrowRect, out Rectangle bottomRightArrowRect, out Rectangle thumbRect)
        {
            Win32.Struct.RECT lpRect = new Win32.Struct.RECT();
            Win32.NativeMethods.GetWindowRect(scrollBarHWnd, ref lpRect);
            Win32.NativeMethods.OffsetRect(ref lpRect, -lpRect.Left, -lpRect.Top);
            int arrowWidth = bHorizontal ? this.ArrowCx : this.ArrowCy;

            bounds = lpRect.Rect;
            System.Drawing.Point point = this.GetScrollBarThumb(bounds, bHorizontal, arrowWidth);
            trackRect = bounds;
            if (bHorizontal)
            {
                topLeftArrowRect     = new Rectangle(0, 0, arrowWidth, bounds.Height);
                bottomRightArrowRect = new Rectangle(bounds.Width - arrowWidth, 0, arrowWidth, bounds.Height);
                if (this._owner.RightToLeft == RightToLeft.Yes)
                {
                    thumbRect = new Rectangle(point.Y, 0, point.X - point.Y, bounds.Height);
                }
                else
                {
                    thumbRect = new Rectangle(point.X, 0, point.Y - point.X, bounds.Height);
                }
            }
            else
            {
                topLeftArrowRect     = new Rectangle(0, 0, bounds.Width, arrowWidth);
                bottomRightArrowRect = new Rectangle(0, bounds.Height - arrowWidth, bounds.Width, arrowWidth);
                thumbRect            = new Rectangle(0, point.X, bounds.Width, point.Y - point.X);
            }
        }
Ejemplo n.º 2
0
 private void CalculateRect(IntPtr scrollBarHWnd, bool bHorizontal, out Rectangle bounds, out Rectangle trackRect, out Rectangle topLeftArrowRect, out Rectangle bottomRightArrowRect, out Rectangle thumbRect)
 {
     Win32.Struct.RECT lpRect = new Win32.Struct.RECT();
     Win32.NativeMethods.GetWindowRect(scrollBarHWnd, ref lpRect);
     Win32.NativeMethods.OffsetRect(ref lpRect, -lpRect.Left, -lpRect.Top);
     int arrowWidth = bHorizontal ? this.ArrowCx : this.ArrowCy;
     bounds = lpRect.Rect;
     System.Drawing.Point point = this.GetScrollBarThumb(bounds, bHorizontal, arrowWidth);
     trackRect = bounds;
     if (bHorizontal)
     {
         topLeftArrowRect = new Rectangle(0, 0, arrowWidth, bounds.Height);
         bottomRightArrowRect = new Rectangle(bounds.Width - arrowWidth, 0, arrowWidth, bounds.Height);
         if (this._owner.RightToLeft == RightToLeft.Yes)
         {
             thumbRect = new Rectangle(point.Y, 0, point.X - point.Y, bounds.Height);
         }
         else
         {
             thumbRect = new Rectangle(point.X, 0, point.Y - point.X, bounds.Height);
         }
     }
     else
     {
         topLeftArrowRect = new Rectangle(0, 0, bounds.Width, arrowWidth);
         bottomRightArrowRect = new Rectangle(0, bounds.Height - arrowWidth, bounds.Width, arrowWidth);
         thumbRect = new Rectangle(0, point.X, bounds.Width, point.Y - point.X);
     }
 }
Ejemplo n.º 3
0
        private ScrollBarHistTest ScrollBarHitTest(IntPtr hWnd)
        {
            Win32.NativeMethods.Point lpPoint        = new Win32.NativeMethods.Point();
            Win32.Struct.RECT         lpRect         = new Win32.Struct.RECT();
            System.Drawing.Point      scrollBarThumb = this.GetScrollBarThumb();
            int arrowCx = this.ArrowCx;
            int arrowCy = this.ArrowCy;

            Win32.NativeMethods.GetWindowRect(hWnd, ref lpRect);
            Win32.NativeMethods.OffsetRect(ref lpRect, -lpRect.Left, -lpRect.Top);
            Win32.Struct.RECT lprc = lpRect;
            Win32.NativeMethods.GetCursorPos(ref lpPoint);
            Win32.NativeMethods.ScreenToClient(hWnd, ref lpPoint);
            if (this.Direction == Orientation.Horizontal)
            {
                if (Win32.NativeMethods.PtInRect(ref lpRect, lpPoint))
                {
                    lprc.Right = arrowCx;
                    if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                    {
                        return(ScrollBarHistTest.LeftArrow);
                    }
                    lprc.Left  = lpRect.Right - arrowCx;
                    lprc.Right = lpRect.Right;
                    if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                    {
                        return(ScrollBarHistTest.RightArrow);
                    }
                    if (this._owner.RightToLeft == RightToLeft.Yes)
                    {
                        lprc.Left  = lpPoint.y;
                        lprc.Right = lpPoint.x;
                    }
                    else
                    {
                        lprc.Left  = scrollBarThumb.X;
                        lprc.Right = scrollBarThumb.Y;
                    }
                    if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                    {
                        return(ScrollBarHistTest.Thumb);
                    }
                    return(ScrollBarHistTest.Track);
                }
            }
            else if (Win32.NativeMethods.PtInRect(ref lpRect, lpPoint))
            {
                lprc.Bottom = arrowCy;
                if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                {
                    return(ScrollBarHistTest.TopArrow);
                }
                lprc.Top    = lpRect.Bottom - arrowCy;
                lprc.Bottom = lpRect.Bottom;
                if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                {
                    return(ScrollBarHistTest.BottomArrow);
                }
                lprc.Top    = scrollBarThumb.X;
                lprc.Bottom = scrollBarThumb.Y;
                if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
                {
                    return(ScrollBarHistTest.Thumb);
                }
                return(ScrollBarHistTest.Track);
            }
            return(ScrollBarHistTest.None);
        }
Ejemplo n.º 4
0
 private ScrollBarHistTest ScrollBarHitTest(IntPtr hWnd)
 {
     Win32.NativeMethods.Point lpPoint = new Win32.NativeMethods.Point();
     Win32.Struct.RECT lpRect = new Win32.Struct.RECT();
     System.Drawing.Point scrollBarThumb = this.GetScrollBarThumb();
     int arrowCx = this.ArrowCx;
     int arrowCy = this.ArrowCy;
     Win32.NativeMethods.GetWindowRect(hWnd, ref lpRect);
     Win32.NativeMethods.OffsetRect(ref lpRect, -lpRect.Left, -lpRect.Top);
     Win32.Struct.RECT lprc = lpRect;
     Win32.NativeMethods.GetCursorPos(ref lpPoint);
     Win32.NativeMethods.ScreenToClient(hWnd, ref lpPoint);
     if (this.Direction == Orientation.Horizontal)
     {
         if (Win32.NativeMethods.PtInRect(ref lpRect, lpPoint))
         {
             lprc.Right = arrowCx;
             if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
             {
                 return ScrollBarHistTest.LeftArrow;
             }
             lprc.Left = lpRect.Right - arrowCx;
             lprc.Right = lpRect.Right;
             if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
             {
                 return ScrollBarHistTest.RightArrow;
             }
             if (this._owner.RightToLeft == RightToLeft.Yes)
             {
                 lprc.Left = lpPoint.y;
                 lprc.Right = lpPoint.x;
             }
             else
             {
                 lprc.Left = scrollBarThumb.X;
                 lprc.Right = scrollBarThumb.Y;
             }
             if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
             {
                 return ScrollBarHistTest.Thumb;
             }
             return ScrollBarHistTest.Track;
         }
     }
     else if (Win32.NativeMethods.PtInRect(ref lpRect, lpPoint))
     {
         lprc.Bottom = arrowCy;
         if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
         {
             return ScrollBarHistTest.TopArrow;
         }
         lprc.Top = lpRect.Bottom - arrowCy;
         lprc.Bottom = lpRect.Bottom;
         if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
         {
             return ScrollBarHistTest.BottomArrow;
         }
         lprc.Top = scrollBarThumb.X;
         lprc.Bottom = scrollBarThumb.Y;
         if (Win32.NativeMethods.PtInRect(ref lprc, lpPoint))
         {
             return ScrollBarHistTest.Thumb;
         }
         return ScrollBarHistTest.Track;
     }
     return ScrollBarHistTest.None;
 }