/// <summary> /// Method to set the ScrollbarInfo, if we can get it /// </summary> /// <param name="forceUpdate">set to true to force an update, default is false</param> /// <returns>ScrollBarInfo?</returns> public ScrollBarInfo?GetScrollbarInfo(bool forceUpdate = false) { // Prevent updates, if there is already a value if (ScrollBar.HasValue && !forceUpdate) { return(ScrollBar); } var objectId = ObjectIdentifiers.Client; switch (ScrollBarType) { case ScrollBarTypes.Control: objectId = ObjectIdentifiers.Client; break; case ScrollBarTypes.Vertical: objectId = ObjectIdentifiers.VerticalScrollbar; break; case ScrollBarTypes.Horizontal: objectId = ObjectIdentifiers.HorizontalScrollbar; break; } var scrollbarInfo = ScrollBarInfo.Create(); var hasScrollbarInfo = User32Api.GetScrollBarInfo(ScrollBarWindow.Handle, objectId, ref scrollbarInfo); if (!hasScrollbarInfo) { var error = Win32.GetLastErrorCode(); Log.Verbose().WriteLine("Error retrieving Scrollbar info : {0}", Win32.GetMessage(error)); return(null); } ScrollBar = scrollbarInfo; return(scrollbarInfo); }
/// <summary> /// Initialises a new instance of ComboTreeDropDown and associates it with its parent ComboTreeBox. /// </summary> /// <param name="sourceControl"></param> public ComboTreeDropDown(ComboTreeBox sourceControl) { _visibleItems = new List <NodeInfo>(); _bitmaps = new Dictionary <BitmapInfo, Image>(); _scrollBar = new ScrollBarInfo(); AutoSize = false; this._sourceControl = sourceControl; RenderMode = ToolStripRenderMode.System; BackColor = Color.White; _dropDownHeight = 150; _itemHeight = MIN_ITEM_HEIGHT; Items.Add(""); _scrollRepeater = new Timer(); _scrollRepeater.Tick += new EventHandler(scrollRepeater_Tick); }
public bool LastLinesVisible() { var scrollBarInfo = new ScrollBarInfo(); scrollBarInfo.cbSize = Marshal.SizeOf(scrollBarInfo); scrollBarInfo.fMask = 0x10 | 0x1 | 0x2; try { GetScrollInfo(this.Handle, 1, ref scrollBarInfo); } catch { return(true); } //if (_ScrollBarInfo.max == 0) return false; return((scrollBarInfo.max - (scrollBarInfo.nTrackPos + scrollBarInfo.nPage)) < (this.Font.Height * AppendLineAmountOfLastVisibleLinesToAutoScroll_)); }
private int GetScrollValue(ScrollBarInfo info) { NativeMethods.ScrollInfo si = new NativeMethods.ScrollInfo(); si.fMask = NativeMethods.SIF_ALL; si.cbSize = Marshal.SizeOf(si.GetType()); if (!Misc.GetScrollInfo(_hwnd, _sbFlag, ref si)) { return(0); } switch (info) { case ScrollBarInfo.CurrentPosition: // // Builds prior to Vista 5359 failed to correctly account for RTL scrollbar layouts. // if ((Environment.OSVersion.Version.Major < 6) && (_sbFlag == NativeMethods.SB_HORZ) && (Misc.IsControlRTL(_parent._hwnd))) { return(GetScrollMaxValue(si) - si.nPos); } return(si.nPos); case ScrollBarInfo.MaximumPosition: return(GetScrollMaxValue(si)); case ScrollBarInfo.MinimumPosition: return(si.nMin); case ScrollBarInfo.PageSize: return(si.nPage); case ScrollBarInfo.TrackPosition: return(si.nTrackPos); case ScrollBarInfo.LargeChange: return(si.nPage); case ScrollBarInfo.SmallChange: return(1); } return(0); }
private int GetScrollValue (ScrollBarInfo info) { NativeMethods.ScrollInfo si = new NativeMethods.ScrollInfo (); si.fMask = NativeMethods.SIF_ALL; si.cbSize = Marshal.SizeOf (si.GetType ()); if (!Misc.GetScrollInfo(_hwnd, _sbFlag, ref si)) { return 0; } switch (info) { case ScrollBarInfo.CurrentPosition: // // Builds prior to Vista 5359 failed to correctly account for RTL scrollbar layouts. // if ((Environment.OSVersion.Version.Major < 6) && (_sbFlag == NativeMethods.SB_HORZ) && (Misc.IsControlRTL(_parent._hwnd))) { return GetScrollMaxValue(si) - si.nPos; } return si.nPos; case ScrollBarInfo.MaximumPosition: return GetScrollMaxValue(si); case ScrollBarInfo.MinimumPosition: return si.nMin; case ScrollBarInfo.PageSize: return si.nPage; case ScrollBarInfo.TrackPosition: return si.nTrackPos; case ScrollBarInfo.LargeChange: return si.nPage; case ScrollBarInfo.SmallChange: return 1; } return 0; }
public static extern bool GetScrollBarInfo(IntPtr hwnd, ObjectIdentifiers idObject, ref ScrollBarInfo scrollBarInfo);
private static extern int GetScrollInfo(IntPtr hwnd, int nBar, ref ScrollBarInfo scrollInfo);