Search Tools Links Login

Example of how to auto scroll

Teaches you how to auto-scroll a richtextbox, but it accounts for the vertical scrollbar. If the user has the scrollbar moved up, or at the top, it does not scroll down and stay at the bottom. This is very usefull for logging windows or chat windows. There is no code to do this on PSC. I would like to thank BillSoo from for his help in solving this. He gave me the initial code and sent me in the right direction. After fixing it, here it is for everyone to use. This is just a little demo, the timer runs every second adding a line to the box, just watch it go and then play with the scrollbar, it only scrolls down if its already at the bottom.

Original Author: Gregg Housh

API Declarations

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const EM_GETSCROLLPOS = (WM_USER + 221)
Private Const EM_SETSCROLLPOS = (WM_USER + 222)
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_CHARFROMPOS = &HD7
Private Type POINTL
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 91 times


Visual Basic 6

Posted: 9/3/2020 3:45:00 PM
Size: 3,072 bytes

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.