Link to home
Start Free TrialLog in
Avatar of AnderstheCyborg
AnderstheCyborg

asked on

How can I get and set the scrollbar position of a textbox?

As the title says, I am wondering about how to get and set scrollbar positions of a rich textbox control.

I have created an ini programmer, which colors specific codelines.
The whole content of the textbox is refreshed upon repainting, and the selstart is set to what it was before the painting procedure started, but the file is not scrolled down to exactly where it was. It simply use the selstart as the bottom line.

Does anyone know a method to get and set textbox scrollbar positions?
Avatar of drcspy
drcspy
Flag of New Zealand image

JUST what programming language are you talkin here
Avatar of AnderstheCyborg
AnderstheCyborg

ASKER

Sorry for my question's inaccuracy.
The language I am using is Visual Basic 6.0
er, what's this have to do with storage?
ASKER CERTIFIED SOLUTION
Avatar of msa2003
msa2003

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks alot!

That should do the trick.
I am proud to reward you the points, Msa2003 :)
Just what I needed.
Thanks lad
I'm glad to help you.

Serge.
Your solution was good and easy to understand, but the text in the textwindow doesn't scroll when the scrollbar is updated.

If you click on the scrollbar however, the text is "updated", but this is not the meaning.

Does anyone have any solutions to this?
Sorry, but I'm afraid that "anyone" means "msa2003" in this topic area).

You might use the following construction to set the text box position instead of only scroll bar position:

SendMessage(RichEdit1.hWnd, WM_VSCROLL, SB_THUMBPOSITION + Pos * 65536, 0);

constant values:

WM_VSCROLL = 277
SB_THUMBPOSITION = 4

use WM_VSCROLL to scroll vertically and WM_HSCROLL (276) to scroll horisontally.

SendMessage() is an API function (needed to use API Text Viewer) which is used to send a message to the controll (window). The construction prior sends the text box message to scroll to absolute position defined by Pos variable. The Pos value might be retrieved by GetScrollPos function. If you use the prior construction you do not need to use SetScrollPos function.

Sorry, I am not a VB programmer.

Best regards
Serge