Exemple #1
0
        internal void Native_EnableScrollBar(bool enable, int orientation)
        {
            var oriV = orientation == NativeMethods.SB_VERT;
            var oriH = orientation == NativeMethods.SB_HORZ;

            if (enable)
            {
                if (oriV && vscroll == null)
                {
                    vscroll               = new VScrollBar();
                    vscroll.Anchor        = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
                    vscroll.uwfSystem     = true;
                    vscroll.ValueChanged += Scroll_ValueChanged;

                    Controls.Add(vscroll);

                    uwfOnVScrollAdded(EventArgs.Empty);
                }

                if (oriH && hscroll == null)
                {
                    hscroll               = new HScrollBar();
                    hscroll.Anchor        = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
                    hscroll.uwfSystem     = true;
                    hscroll.ValueChanged += Scroll_ValueChanged;

                    Controls.Add(hscroll);

                    uwfOnHScrollAdded(EventArgs.Empty);
                }
            }
            else
            {
                if (oriV && vscroll != null)
                {
                    vscroll.Value         = 0; // Reset view.
                    vscroll.ValueChanged -= Scroll_ValueChanged;
                    vscroll.Dispose();
                    vscroll = null;
                }

                if (oriH && hscroll != null)
                {
                    hscroll.Value         = 0; // Reset view.
                    hscroll.ValueChanged -= Scroll_ValueChanged;
                    hscroll.Dispose();
                    hscroll = null;
                }
            }
        }