/// <summary> /// 响应垂直滚动条滚动事件 /// Occurs when the Table's vertical scrollbar is scrolled /// </summary> /// <param name="sender">The object that Raised the event</param> /// <param name="e">A ScrollEventArgs that contains the event data</param> protected void OnVerticalScroll(object sender, ScrollEventArgs e) { int scrollVal = e.OldValue - e.NewValue; if (scrollVal != 0) { Rectangle invalidateRect = new Rectangle(0, 0, this.Width - VScrollWidth, this.Height - HScrollHeight); I3RECT scrollRect = I3RECT.FromRectangle(invalidateRect); scrollRect.top += 1; I3NativeMethods.ScrollWindow(this.Handle, 0, scrollVal, ref scrollRect, ref scrollRect); if (scrollVal < 0) { invalidateRect.Y = invalidateRect.Bottom + scrollVal; } invalidateRect.Height = Math.Abs(scrollVal) + 1; this.Invalidate(invalidateRect, false); } }
protected void OnHorizontalScroll(object sender, ScrollEventArgs e) { int scrollVal = e.OldValue - e.NewValue; if (scrollVal != 0) { Rectangle invalidateRect = new Rectangle(0, 0, this.Width - VScrollWidth, this.Height - HScrollHeight); I3RECT scrollRect = I3RECT.FromRectangle(invalidateRect); //移动窗体的绘画区 I3NativeMethods.ScrollWindow(this.Handle, scrollVal, 0, ref scrollRect, ref scrollRect); //计算重绘区域 if (scrollVal < 0) { invalidateRect.X = invalidateRect.Right + scrollVal; } invalidateRect.Width = Math.Abs(scrollVal) + 1; this.Invalidate(invalidateRect, false); } }