/// <summary> /// lock window draw if thumb drag in process /// </summary> public void LockWindowDrawOnThumbDrag() { if (_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(this.Handle); } }
/// <summary> /// unlock window draw if thumb drag in process or has ended /// </summary> /// <returns></returns> public bool UnlockWindowDrawOnThumbDrag() { if (_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(IntPtr.Zero); return(true); } else { return(false); } }
/// <summary> /// Update vertical scroll bar /// </summary> /// <param name="calculateRowsInPage">Calculate rows in page before updating scroll bar</param> protected override void updateVScroll(bool calculateRowsInPage) { bool visibleChanged = false; bool hScrollBarExisted; bool hScrollBarExists; if (SuspendPaint) { return; } if (calculateRowsInPage) { ComputeAndSetRowsInPage(false); } hScrollBarExisted = isHscrollShown(); if (isVscrollShown()) { if (isVerticalScrollBarVisible != isVscrollShown()) { // In case of thumb drag window is already locked, no need to lock again if (RightToLeft == RightToLeft.Yes && !_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(this.Handle); } NativeScroll.ShowScrollBar(this.Handle, NativeScroll.SB_VERT, true); if (RightToLeft == RightToLeft.Yes && !_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(IntPtr.Zero); } visibleChanged = true; } // Unlock window and update if (UnlockWindowDrawOnThumbDrag()) { this.Update(); } NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_VERT); sc.nPos = _vScrollThumbPos; sc.nMax = _virtualItemsCount; sc.nPage = PageSize; sc.fMask = NativeScroll.SIF_PAGE | NativeScroll.SIF_RANGE | NativeScroll.SIF_POS; NativeScroll.SetScrollInfo(this.Handle, NativeScroll.SB_VERT, ref sc, true); // lock drawing on the window LockWindowDrawOnThumbDrag(); } else { // If the scrollbar was shown earlier (isVerticalScrollBarVisible is true) and is to be removed // now (isVscrollShown() is false)... if (isVerticalScrollBarVisible) { if (RightToLeft == RightToLeft.Yes && !_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(this.Handle); } // Also, handle scrollbar animation caused due to bug in Windows theme HideVerticalScrollbarAnimationForWindowsThemes(); if (RightToLeft == RightToLeft.Yes && !_isThumbDrag) { NativeWindowCommon.LockWindowUpdate(IntPtr.Zero); } //...end thumb drag. if (_isThumbDrag) { EndThumbDrag(); } visibleChanged = true; } } hScrollBarExists = isHscrollShown(); if (visibleChanged) { OnVScrollBarVisibleChanged(isVscrollShown(), hScrollBarExisted, hScrollBarExists); } isVerticalScrollBarVisible = isVscrollShown(); }