private static extern bool SetScrollInfo(IntPtr hwnd, int bar, ref ScrollInfo scrollInfo, int redraw);
public extern static int SetScrollInfo(IntPtr hWnd, int fnBar, ref ScrollInfo lpsi, bool bRedraw);
void UpdateTextBox(TextBox textBox, string value, bool preserveScroll) { scrollPreserve_[textBox.Handle] = preserveScroll; textBox.Text = value; int previousScroll; if (!scrollPositions_.TryGetValue(textBox.Handle, out previousScroll)) { previousScroll = 0; } var scrollInfo = new ScrollInfo(); scrollInfo.cbSize = Marshal.SizeOf(scrollInfo); scrollInfo.fMask = (uint)ScrollInfoMask.SIF_TRACKPOS; scrollInfo.nTrackPos = previousScroll; SetScrollInfo(textBox.Handle, SB_VERT, ref scrollInfo, 1); var ptrWparam = new IntPtr(SB_THUMBPOSITION | previousScroll << 16); SendMessage(textBox.Handle, WM_VSCROLL, ptrWparam, IntPtr.Zero); }
public void ScrollToEnd() { if (Log.IsDebugEnabled) Log.Debug("ScrollToEnd"); //NOTE: Following didn't work well enough. //SelectionStart = TextLength; //ScrollToCaret(); // Get the current scroll info. ScrollInfo si = new ScrollInfo(); si.Size = (uint) Marshal.SizeOf(si); si.Mask = (uint) ScrollInfoMask.All; GetScrollInfo(Handle, (int) ScrollBarDirection.Vertical, ref si); // Set the scroll position to maximum. si.Pos = si.Max - (int) si.Page; SetScrollInfo(Handle, (int) ScrollBarDirection.Vertical, ref si, true); SendMessage(Handle, VerticalScroll, new IntPtr(Thumbtrack + 0x10000 * si.Pos), new IntPtr(0)); FollowTail = true; }
public AutoScrollHelper(GridView view) { fGrid = view.GridControl; fView = view; fScrollInfo = new ScrollInfo(this, view); }
/// <summary> /// Get current position /// </summary> /// <returns>SCROLLINFO</returns> public bool GetPosition(out ScrollInfo scrollInfo) { scrollInfo = ScrollInfo.Create(ScrollInfoMask.All); return(User32Api.GetScrollInfo(ScrollBarWindow.Handle, ScrollBarType, ref scrollInfo)); }
public static extern bool GetScrollInfo(IntPtr hwnd, ScrollBarTypes scrollBar, ref ScrollInfo scrollInfo);
public static extern bool GetScrollInfo(int wnd, int bat, [In, Out] ScrollInfo si);
public AuScrollableControl() { _h.cbSize = _v.cbSize = Api.SizeOf(_h); _h.nMax = _v.nMax = 100; _e = new ScrollInfo(); }
static extern int GetScrollInfo(IntPtr window, ScrollOrientation bar, out ScrollInfo info);
public static extern int SetScrollInfo(int wnd, int bar, ScrollInfo si, bool redraw);
private int SetColumnCount(ScrollInfo info) => _Columns = Math.Max((int)Math.Floor(info.ClientWidth / ItemWidth), 1);
private extern static int SetScrollInfo(IntPtr hWnd, int nBar, ref ScrollInfo Info, int bRedraw);
private extern static int GetScrollInfo(IntPtr hWnd, int nBar, ref ScrollInfo Info);
private static extern int SetScrollInfo(IntPtr hWnd, int nBar, ref ScrollInfo Info, int bRedraw);
private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref ScrollInfo lpsi);
public AutoScrollHelper(LayoutView view) { fGrid = view.GridControl; fView = view; fScrollInfo = new ScrollInfo(this, view); }
void scaleZoomHelper_Scrolled(ScrollInfo scrollInfo) { _timeAxis.Zoom( scrollInfo.Delta < 0 ? 2 : 0.5, _onlineMode.IsOnline ? 1 : scrollInfo.RelativePosition); }
public static extern int GetScrollInfo(IntPtr hwnd, int nBar, ref ScrollInfo scrollInfo);
public static extern bool GetScrollInfo(IntPtr hWnd, int n, ref ScrollInfo lpScrollInfo);
public static extern bool SetScrollInfo(IntPtr hwnd, ScrollBarTypes scrollBar, ref ScrollInfo scrollInfo, bool redraw);
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { ScrollInfo si; switch (message) { case MessageType.Size: int iMaxWidth = 40 * cxChar + 22 * cxCaps; cxClient = lParam.LowWord; cyClient = lParam.HighWord; // Set vertical scroll bar range and page size si = new ScrollInfo { Mask = ScrollInfoMask.Range | ScrollInfoMask.Page, Min = 0, Max = Metrics.SystemMetrics.Count - 1, Page = (uint)(cyClient / cyChar), }; window.SetScrollInfo(ScrollBar.Vertical, ref si, true); // Set horizontal scroll bar range and page size si.Max = 2 + iMaxWidth / cxChar; si.Page = (uint)(cxClient / cxChar); window.SetScrollInfo(ScrollBar.Horizontal, ref si, true); return(0); case MessageType.VerticalScroll: // Get all the vertical scroll bar information si = new ScrollInfo { Mask = ScrollInfoMask.All }; window.GetScrollInfo(ScrollBar.Vertical, ref si); // Save the position for comparison later on int iVertPos = si.Position; switch ((ScrollCommand)wParam.LowWord) { case ScrollCommand.Top: si.Position = si.Min; break; case ScrollCommand.Bottom: si.Position = si.Max; break; case ScrollCommand.LineUp: si.Position -= 1; break; case ScrollCommand.LineDown: si.Position += 1; break; case ScrollCommand.PageUp: si.Position -= (int)si.Page; break; case ScrollCommand.PageDown: si.Position += (int)si.Page; break; case ScrollCommand.ThumbTrack: si.Position = si.TrackPosition; break; } // Set the position and then retrieve it. Due to adjustments // by Windows it may not be the same as the value set. si.Mask = ScrollInfoMask.Position; window.SetScrollInfo(ScrollBar.Vertical, ref si, true); window.GetScrollInfo(ScrollBar.Vertical, ref si); // If the position has changed, scroll the window and update it if (si.Position != iVertPos) { window.ScrollWindow(new Point(0, cyChar * (iVertPos - si.Position))); window.UpdateWindow(); } return(0); case MessageType.HorizontalScroll: // Get all the horizontal scroll bar information si = new ScrollInfo { Mask = ScrollInfoMask.All }; window.GetScrollInfo(ScrollBar.Horizontal, ref si); // Save the position for comparison later on int iHorzPos = si.Position; switch ((ScrollCommand)wParam.LowWord) { case ScrollCommand.LineLeft: si.Position -= 1; break; case ScrollCommand.LineRight: si.Position += 1; break; case ScrollCommand.PageLeft: si.Position -= (int)si.Page; break; case ScrollCommand.PageRight: si.Position += (int)si.Page; break; case ScrollCommand.ThumbPosition: si.Position = si.TrackPosition; break; } // Set the position and then retrieve it. Due to adjustments // by Windows it may not be the same as the value set. si.Mask = ScrollInfoMask.Position; window.SetScrollInfo(ScrollBar.Horizontal, ref si, true); window.GetScrollInfo(ScrollBar.Horizontal, ref si); // If the position has changed, scroll the window if (si.Position != iHorzPos) { window.ScrollWindow(new Point(cxChar * (iHorzPos - si.Position), 0)); } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint(out PaintStruct ps)) { // Get vertical scroll bar position si = new ScrollInfo { Mask = ScrollInfoMask.Position }; window.GetScrollInfo(ScrollBar.Vertical, ref si); iVertPos = si.Position; // Get horizontal scroll bar position window.GetScrollInfo(ScrollBar.Horizontal, ref si); iHorzPos = si.Position; // Find painting limits int iPaintBeg = Math.Max(0, iVertPos + ps.Paint.Top / cyChar); int iPaintEnd = Math.Min(Metrics.SystemMetrics.Count - 1, iVertPos + ps.Paint.Bottom / cyChar); var keys = Metrics.SystemMetrics.Keys.ToArray(); for (int i = iPaintBeg; i <= iPaintEnd; i++) { var metric = keys[i]; int x = cxChar * (1 - iHorzPos); int y = cyChar * (i - iVertPos); dc.TextOut(new Point(x, y), metric.ToString().AsSpan()); dc.TextOut(new Point(x + 22 * cxCaps, y), Metrics.SystemMetrics[metric].AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Right, TextAlignment.Vertical.Top)); dc.TextOut(new Point(x + 22 * cxCaps + 40 * cxChar, y), Windows.GetSystemMetrics(metric).ToString().AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Left, TextAlignment.Vertical.Top)); } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
static extern bool GetScrollInfo(IntPtr hWnd, int scrollDirection, ref ScrollInfo si);
public static extern bool GetScrollInfo(IntPtr hWnd, int nBar, ref ScrollInfo lpScrollInfo);
public extern static int GetScrollInfo(IntPtr hWnd, int fnBar, ref ScrollInfo lpsi);
public static extern bool SetScrollInfo(int hwnd, int nBar, ref ScrollInfo lpcScrollInfo, bool redraw);
void UpdateScrollStates() { foreach (var handle in scrollPreserve_.Keys) { if (scrollPreserve_[handle]) { var scrollInfo = new ScrollInfo(); scrollInfo.cbSize = Marshal.SizeOf(scrollInfo); scrollInfo.fMask = (uint)ScrollInfoMask.SIF_TRACKPOS; bool hasScrollInfo = GetScrollInfo(handle, SB_VERT, ref scrollInfo); scrollPositions_[handle] = scrollInfo.nTrackPos; } } }
public static extern int SetScrollInfo(IntPtr hwnd, int nBar, ref ScrollInfo lpcScrollInfo, bool redraw);
private static extern bool GetScrollInfo(IntPtr hwnd, int bar, ref ScrollInfo scrollInfo);
public InvertedVCrkScrollBar(ScrollInfo info) : base(info) { }
private static extern int GetScrollInfo(IntPtr hWnd, int nBar, ref ScrollInfo Info);
public static extern int GetScrollInfo(IntPtr hWnd, int n, ref ScrollInfo lpScrollInfo);
public static ScrollInfo Create(uint uiMask) { ScrollInfo Info = new ScrollInfo(); Info.cbSize = (uint)Marshal.SizeOf(typeof(ScrollInfo)); Info.fMask = uiMask; return Info; }
public static extern int SetScrollInfo(IntPtr hwnd, int fnBar, [In] ref ScrollInfo lpsi, bool fRedraw);