Rubrik: Controls · TextBox & RichTextBox | VB-Versionen: VB4, VB5, VB6 | 18.03.01 |
Dieser Tipp zeigt, wie man den Inhalt einer Textbox per Code nach links oder rechts scrollen kann. Plazieren Sie hierzu ein Textelement und zwei Command-Buttons auf eine Form. Setzen Sie die Textbox-Eigenschaft Multiline auf True und ScrollBars auf 1 - horizontal.
' zunächst die benötigten API-Deklarationen
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Const WM_HSCROLL = &H114
Const SB_LINERIGHT = 1
Const SB_LINELEFT = 0
Private Function fScrollLeft()
Dim lRet As Long
lRet = SendMessage(Text1.hwnd, WM_HSCROLL, _
SB_LINELEFT, ByVal 0&)
End Function
Private Function fScrollRight()
Dim lRet As Long
lRet = SendMessage(Text1.hwnd, WM_HSCROLL, _
SB_LINERIGHT, ByVal 0&)
End Function
Private Sub Form_Load()
Text1.Text = "Test Textbox automatisch " + _
"scrollen by www.Visual-Basic5.de"
End Sub
Private Sub Command1_Click()
' links scrollen
fScrollLeft
End Sub
Private Sub Command2_Click()
' links scrollen
fScrollRight
End Sub