detect/control changes in built-in scrollbar of RichTextBox

mervbit used Ask the Experts™
I would like to synchronize the scrollbars of several different RichTextboxes in an application.  But the only scrollbar properties available in the RichTextbox property set are whether or not scrollbars are enabled.  There doesn't even seem to be any event generated by the movement of a RTBox scrollbar.  Is there any way my code can access and change these scrollbar properties in the same way that is available for VB stand-alone scrollbars?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The only way I can think of to do this is to subclass the message stream going to the Rich TextBoxes.  You are looking for messages:
WM_VSCROLL (SB_LINEDOWN, SB_LINEUP, SB_THUMBTRACK - used for when they grab the thumb and drag it)  WPARAM =1  means scrolled single line.  WPARAM = 8 means scrolled uwing a click inside the scrollbar body.

If you don't know how to subclass, I can provide that code for you, but you're going to have to play around with the messages till you get it right.  You will also have to send the same messages you are receiving to the other richtextboxes.



This is a bit involved for me -- given that I don't even know what "sub-classing a message stream" is!  If it is really simple, I'm game to give it a shot, but since this is a non-critical part of my application, I'm inclined to just drop it.  What I'm saying is:  don't spend a lot of time coming up with code for me unless you can do it in a couple minutes or less.

Here's a site describing subclassing.  Since you're ready to drop the issue, it wouldn't be worth it to go through and try to trap the correct messages and perform the synchronization.  It would probably take about a half-hour to get there from here, but thought you might like to see the subclassing code.  It would simply be a matter of trapping the messages I said, but the challenge will be in sending the messages to the other RTB controls.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


Thanks for the link -- I checked it out, and it was way over my head!  Thanks anyway.

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- answered by twalgrave
Please leave any comments here within the
next seven days.


Cleanup Volunteer
per recommendation

Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial