VBcoders Guest

Don't have an account yet? Register

Forgot Password?


by CptnVic (6 Submissions)
Category: Windows API Call/Explanation
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This small very fast code demonstrates the use of EM_LINESCROLL (sendmessage api)to to automatically, instantly, precisely, and simultaneously scroll 1 or several RichText, Text box, or List boxes. If you build chat interfaces, or are building a code editor... this code is for you! Even the rankest beginner will be able to understand and use this code in minutes. There's more comments than code!
I got the idea while using KRYO_11's external scroll bar code (found here on VBC). His code uses the EM_SCROLL message and a for/next loop that works fine for small text boxes... but goes a little nutty when the text box is tall and there are many lines to scroll.
The EM_LINESCROLL message does not "Scroll" to the new position... it jumps there similar to the GoTo statement in VB. It is VERY FAST!
I needed this yesterday... but couldn't find it anywhere... even a text search of VBC's code returned only one instance of a chat bot that didn't appear to really use the EM_LINESCROLL message... so if there is ANY similar code on VBC, it is well hidden indeed!
The project contains 2 demos:
1) Compares the EM_SCROLL and EM_LINESCROLL messages and speed of their use.
2) This demo simultaneously scrolls several RTBs, a text box and a list box from 1 regular old VB scrollbar. It will also teach you how to sync up the objects so they not only scroll together... but scroll the right lines together... and quickly.
Hope You Enjoy The Code!

You must drag the scrollbars
Even the newest to coding will be able to follow this code.
Code Returns
Scrolled text
Side Effects
It's bug free or I wouldn't submit it!
API Declarations
Private Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)

Rate AutoScroll EMLINESCROLL Demo

Download AutoScroll EMLINESCROLL Demo

Download AutoScroll EMLINESCROLL Demo (9 KB)

AutoScroll EMLINESCROLL Demo Comments

No comments have been posted about AutoScroll EMLINESCROLL Demo. Why not be the first to post a comment about AutoScroll EMLINESCROLL Demo.

Post your comment

0/1000 characters