Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolling large text box navigation simulation

Status
Not open for further replies.

gymbeef

Technical User
Sep 18, 2002
33
US
I have a large unbound text box on a form that is essentially used as a text editor. If I click on the box, I can then "scroll" up and down using the keyboard's arrow keys to see text that falls "off the page". The textbox must be enabled however for that to work, and the cursor appears "within" the text-box.

What I want to do is create a more sophisticated interface that will "scroll" with both enabled and disabled text-boxes from outside the control. A neat "slider-bar" would be the coolest, but the easier way out is to have a "scroll up" and a "scroll down" button to reposition the text in the box (having both a slider bar and buttons would essentially simulate the standard windows style navigation).

I know how to position the cursor using SelStart for example, but I don't know if thats where I need to start thinking. It's not the position of the cursor that I need to manipulate anyways, its the position of the text in the text-box.

Any suggestions?


 
INTERESTING!!
WHAT ABOUT SETTING THE ENTIRE CONTENTS OF THE TEXT BOX AS ONE STRING AND USING A CLICK EVENT TO POSITION THE CURSOR 20(?) CHARACTERS FURTHER ALONG EACH TIME.

I ASSUME THE TEXTBOX CAN TAKE 65000 CHARS. IF NOT THEN WE CAN SIMPLY STORE THE TEXT IN A TABLE FIELD FORMATTED AS 'MEMO'
LET ME KNOW HOW IT WENT
JOHN
 
ADDENDUM TO THE LAST POSTING!!!
IF YOU PRE-DETERMINE THE CHAR WIDTH OF THE TEXT BOX (e.g. 50 characters) THEN YOUR STEP SIZE FOR EACH CLICK EVENT WILL BE 50 WON'T IT!! Q.E.D
JOHN
 
well, it kinda works, using SelStart to position the cursor. But the problem is that SelStart positions by character count, but its not a "solid" textbox. What I mean is that if it was "shoulder-to-shoulder" with characters throughout, then you could step through it based on how many characters display in the "visible" part of the textbox. But if you have
lines like
these
where there are variable amounts
of characters
in each line, then the character count gets skewed due to the "missing" characters which don't fill out the full line across to the right. In other words, SelStart counts by individual digits, while the text display in the box is based on lines across: SelStart @ 50 puts you at the end of a 50 character line, but puts you five lines down if each line only contains 10 characters each.

You'd have to use a more brute force method to find out where the CR\LF's are, then figure out how many "blank spaces" in the line to the right those cause, and then count including those "blanks" to return consistent results.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top