VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Example of how to auto scroll

by Gregg Housh (10 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (11 Votes)

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 VBC. I would like to thank BillSoo from www.visualbasicforum.com 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.

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 Const EM_GETLINECOUNT = &HBA
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

Rate Example of how to auto scroll

Download Example of how to auto scroll

Download Example of how to auto scroll (3 KB)

Example of how to auto scroll Comments

No comments have been posted about Example of how to auto scroll. Why not be the first to post a comment about Example of how to auto scroll.

Post your comment

Subject:
Message:
0/1000 characters