/// <summary> /// Go to the previous "page" /// </summary> /// <returns>bool if this worked</returns> public bool Previous() { var result = false; ScrollInfo scrollInfoBefore; var hasScrollInfo = TryRetrievePosition(out scrollInfoBefore); switch (ScrollMode) { case ScrollModes.KeyboardPageUpDown: result = InputGenerator.KeyPress(VirtualKeyCodes.PRIOR) == 2; break; case ScrollModes.WindowsMessage: result = SendScrollMessage(ScrollBarCommands.SB_PAGEUP); break; case ScrollModes.AbsoluteWindowMessage: if (!hasScrollInfo) { return(false); } // Calculate previous position, clone the scrollInfoBefore var scrollInfoForPrevious = scrollInfoBefore; scrollInfoForPrevious.Position = Math.Max(scrollInfoBefore.Minimum, scrollInfoBefore.Position - (int)scrollInfoBefore.PageSize); result = ApplyPosition(ref scrollInfoForPrevious); break; case ScrollModes.MouseWheel: var bounds = ScrollingWindow.GetInfo().Bounds; var middlePoint = new NativePoint(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2); result = InputGenerator.MoveMouseWheel(WheelDelta, middlePoint) == 1; break; } return(result); }