/// <summary> /// Gets the sroll bar position of the list view. /// </summary> /// <param name="control">The list view.</param> /// <returns>The scroll bar position.</returns> /// <exception cref="System.ArgumentNullException">control</exception> public static int GetVerticalScrollBarPosition(this Control control) { control.ThrowIfNull(nameof(control)); Scrollinfo currentInfo = new Scrollinfo(); currentInfo.cbSize = Marshal.SizeOf(currentInfo); currentInfo.fMask = (int)ScrollInfoMask.SIF_ALL; GetScrollInfo(control.Handle, (int)ScrollBarDirection.SB_VERT, ref currentInfo); return(currentInfo.nPos); }
public static extern int SetScrollInfo(HandleRef hWnd, int fnBar, Scrollinfo si, bool redraw);
private static extern int GetScrollInfo(IntPtr hwnd, int fnBar, ref Scrollinfo lpsi);
public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref Scrollinfo lpsi);
public static extern int SetScrollInfo(IntPtr hwnd, int fnBar, [In] ref Scrollinfo lpsi, bool fRedraw);
/// <summary> /// Gets the sroll bar position of the list view. /// </summary> /// <param name="control">The list view.</param> /// <returns>The scroll bar position.</returns> /// <exception cref="System.ArgumentNullException">control</exception> public static int GetVerticalScrollBarPosition(this Control control) { control.ThrowIfNull(nameof(control)); Scrollinfo currentInfo = new Scrollinfo(); currentInfo.cbSize = Marshal.SizeOf(currentInfo); currentInfo.fMask = (int)ScrollInfoMask.SIF_ALL; GetScrollInfo(control.Handle, (int)ScrollBarDirection.SB_VERT, ref currentInfo); return currentInfo.nPos; }