Scrolls the text in a TextBox or RichEdir vertically or horizontally.
object.Scroll(x , y)
object.ScrollCaret()
object | : TextBox, RichEdit |
Scroll(x, y) scrolls the text vertically or horizontally in a multi-line edit control where:
x Specifies the number of characters to scroll horizontally.
y Specifies the number of lines to scroll vertically.
Scroll(x, y) works like a function and returns an Empty value; similar to in-built APIs, Scroll must be prefaced with ~ or Void, otherwise the 'Something Missing' error will be raised.
ScrollCaret scrolls the caret into view in the control.
OpenW 1
Ocx TextBox tb = "", 10, 10, 300, 300 : .MultiLine = True : .ScrollBars = 2 : .BorderStyle = 1
Global Int32 n, tbpos
For n = 0 To Screen.FontCount - 1
tb.Text = tb.Text & Screen.Fonts(n) & ", "
Next n
Ocx Command cmd(1) = "Scroll Up", 320, 10, 100, 22
Ocx Command cmd(3) = "Scroll Down", 320, 40, 100, 22
Ocx Command cmd(4) = "Scroll to Caret", 320, 70, 100, 22
Do : Sleep : Until Win_1 Is Nothing
Sub cmd_Click(Index%)
tb.SetFocus
If Index% = 4 Then tb.ScrollCaret : Exit Sub
~tb.Scroll(0, (Index% - 2) * 3)
EndSub
Sub tb_GotFocus
tb.SelStart = tbpos
EndSub
Sub tb_LostFocus
If Not tb Is Nothing Then tbpos = tb.SelStart
EndSub
{Created by Sjouke Hamstra; Last updated: 14/06/2022 by James Gaite}