Пример #1
0
 internal static extern bool GetScrollBarInfo(IntPtr hwnd, uint idObject, ref SCROLLBARINFO psbi);
Пример #2
0
        protected override void UpdateDXScrollBar(bool isHorz)
        {
            if (IsLockUpdate)
            {
                return;
            }
            ScrollBarBase dxScroll = isHorz ? (ScrollBarBase)HScroll : (ScrollBarBase)VScroll;

            if (SourceControl == null)
            {
                return;
            }
            if (!SourceControl.IsHandleCreated || !dxScroll.Parent.IsHandleCreated)
            {
                dxScroll.Visible = false;
                return;
            }
            BeginUpdate();
            try
            {
                SCROLLBARINFO sbInfo = new SCROLLBARINFO();
                sbInfo.Init();
                SCROLLBARINFO.GetScrollBarInfo(SourceControl.Handle, isHorz ? SCROLLBARINFO.OBJID_HSCROLL : SCROLLBARINFO.OBJID_VSCROLL, ref sbInfo);
                Rectangle scrollBounds = sbInfo.rcScrollBar.ToRectangle();
                if ((SourceControl != null && !SourceControl.Visible) || scrollBounds.IsEmpty || sbInfo.rgstate0 == SCROLLBARINFO.STATE_SYSTEM_INVISIBLE || sbInfo.rgstate0 == SCROLLBARINFO.STATE_SYSTEM_OFFSCREEN)
                {
                    dxScroll.Visible = false;
                    return;
                }
                scrollBounds = dxScroll.Parent.RectangleToClient(scrollBounds);

                if (isHorz)
                {
                    scrollBounds.Height = fWidth;
                }
                else
                {
                    scrollBounds.Width = fWidth;
                }
                dxScroll.Bounds = scrollBounds;
                ScrollArgs currentArgs = new ScrollArgs(dxScroll), args = new ScrollArgs();
                if (sbInfo.rgstate0 == SCROLLBARINFO.STATE_SYSTEM_UNAVAILABLE)
                {
                    args.Maximum = args.Minimum = 0;
                    args.Value   = 0;
                    args.Enabled = false;
                }
                else
                {
                    SCROLLINFO sInfo = new SCROLLINFO();
                    sInfo.Init();
                    SCROLLINFO.GetScrollInfo(SourceControl.Handle, isHorz ? SCROLLINFO.SB_HORZ : SCROLLINFO.SB_VERT, ref sInfo);
                    args.Enabled     = true;
                    args.Maximum     = sInfo.nMax;
                    args.Minimum     = sInfo.nMin;
                    args.LargeChange = sInfo.nPage;
                    args.SmallChange = isHorz ? 8 : 1;
                    args.Value       = sInfo.nTrackPos;
                }
                dxScroll.Visible = true;
                if (currentArgs.IsEquals(args))
                {
                    return;
                }
                args.AssignTo(dxScroll);
            }
            finally
            {
                EndUpdate();
            }
        }