Exemplo n.º 1
0
        /// <summary>
        /// Updates the horizontal scrollbar.
        /// </summary>
        protected virtual void UpdateHorizontalScrollbar()
        {
            NativeMethods.SCROLLINFO scrollInfo;
            int scrollWidth;
            int pageWidth;

            scrollWidth = this.ScrollSize.Width - 1;
            pageWidth   = this.PageSize.Width;

            if (scrollWidth < 1)
            {
                scrollWidth = 0;
                pageWidth   = 1;
            }

            scrollInfo       = new NativeMethods.SCROLLINFO();
            scrollInfo.fMask = NativeMethods.SIF.SIF_PAGE | NativeMethods.SIF.SIF_RANGE;
            if (this.AlwaysShowHScroll || !this.Enabled)
            {
                scrollInfo.fMask |= NativeMethods.SIF.SIF_DISABLENOSCROLL;
            }
            scrollInfo.nMin  = 0;
            scrollInfo.nMax  = scrollWidth;
            scrollInfo.nPage = pageWidth;

            this.SetScrollInfo(ScrollOrientation.HorizontalScroll, scrollInfo, true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the vertical scrollbar.
        /// </summary>
        protected virtual void UpdateVerticalScrollbar()
        {
            NativeMethods.SCROLLINFO scrollInfo;
            int scrollHeight;
            int pageHeight;

            scrollHeight = this.ScrollSize.Height - 1;
            pageHeight   = this.PageSize.Height;

            if (scrollHeight < 1)
            {
                scrollHeight = 0;
                pageHeight   = 1;
            }

            scrollInfo       = new NativeMethods.SCROLLINFO();
            scrollInfo.fMask = NativeMethods.SIF.SIF_PAGE | NativeMethods.SIF.SIF_RANGE;
            if (AlwaysShowVScroll)
            {
                scrollInfo.fMask |= NativeMethods.SIF.SIF_DISABLENOSCROLL;
            }
            scrollInfo.nMin  = 0;
            scrollInfo.nMax  = scrollHeight;
            scrollInfo.nPage = pageHeight;

            this.SetScrollInfo(ScrollOrientation.VerticalScroll, scrollInfo, true);
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Set the given scrollbar's tracking position to the specified value
        /// </summary>
        /// <param name="scrollbar">The scrollbar.</param>
        /// <param name="value">The value.</param>
        protected virtual void ScrollTo(ScrollOrientation scrollbar, int value)
        {
            NativeMethods.SCROLLINFO oldInfo;

            oldInfo = this.GetScrollInfo(scrollbar);

            if (value > ((oldInfo.nMax - oldInfo.nMin) + 1) - oldInfo.nPage)
            {
                value = ((oldInfo.nMax - oldInfo.nMin) + 1) - oldInfo.nPage;
            }
            if (value < oldInfo.nMin)
            {
                value = oldInfo.nMin;
            }

            if (oldInfo.nPos != value)
            {
                NativeMethods.SCROLLINFO scrollInfo;

                scrollInfo       = new NativeMethods.SCROLLINFO();
                scrollInfo.fMask = NativeMethods.SIF.SIF_POS;
                scrollInfo.nPos  = value;
                this.SetScrollInfo(scrollbar, scrollInfo, true);

                this.OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, oldInfo.nPos, value, scrollbar));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   Gets scrollbar properties
        /// </summary>
        /// <param name="scrollbar">The bar.</param>
        /// <returns></returns>
        private NativeMethods.SCROLLINFO GetScrollInfo(ScrollOrientation scrollbar)
        {
            NativeMethods.SCROLLINFO info;

            info       = new NativeMethods.SCROLLINFO();
            info.fMask = NativeMethods.SIF.SIF_ALL;

            NativeMethods.GetScrollInfo(this.Handle, (int)scrollbar, info);

            return(info);
        }
Exemplo n.º 5
0
 /// <summary>
 ///   Sets scrollbar properties.
 /// </summary>
 /// <param name="scrollbar">The scrollbar.</param>
 /// <param name="scrollInfo">The scrollbar properties.</param>
 /// <param name="refresh">
 ///   if set to <c>true</c> the scrollbar will be repainted.
 /// </param>
 /// <returns></returns>
 // ReSharper disable UnusedMethodReturnValue.Local
 private int SetScrollInfo(ScrollOrientation scrollbar, NativeMethods.SCROLLINFO scrollInfo, bool refresh) // ReSharper restore UnusedMethodReturnValue.Local
 {
     return(NativeMethods.SetScrollInfo(this.Handle, (int)scrollbar, scrollInfo, refresh));
 }