[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

I need help customizing a vertical scrollbar for a richtextbox

I'd like help with some code that can accomplish the following:

1) A vertical scrollbox that scrolls from the bottom such as a chatwindow uses. The built in scrollbar for the richtextbox I want to scroll is not an option as I need to keep the richtextbox disabled. The VScrollbar wants to scroll from the top down(probably just a math issue here).
2) When scrolling the vertical scrollbox up, it should scroll the text in the richtextbox down. When I reach the top of the vertical scrollbox it should be at line 1 of the richtextbox or the beginning of the text in it as I only allow a length of 20000.
3) It would be nice if the vertical scrollbox could have a background color of grey as opposed to the white of the VScrollbar.
4)I'd also like the richtextbox to remain at the point it was scrolled to even as data is being added. In other words, the text would remain at the point I scrolled to until I move it back to the bottom. Then it would continue scrolling when I scroll to the bottom end. I currrently add the text to the bottom of the richtextbox and it does scroll correctly.
5) Is there also a way to incorporate it so that when scolling up small, it will scroll only 1 line at a time. My concern is having the next valid full line being displayed at the bottom. What I mean is, I don't want a line to be cut in 1/2 horizontally, so you only see the characters tops or some there of.

I'm pretty close with this but would like some nice tight code to accomplish it all. I am using VB6. Thnak you in advance for any and all help
0
Computron
Asked:
Computron
1 Solution
 
STStheBestCommented:
1) A vertical scrollbox that scrolls from the bottom such as a chatwindow uses. The built in scrollbar for the richtextbox I want to scroll is not an option as I need to keep the richtextbox disabled. The VScrollbar wants to scroll from the top down(probably just a math issue here).

I haven't looked for an answer yet, but a small remark: Isn't it true that you can scroll while the rtf-textbox is Locked (instead of disabled)? Or is it really important that users can't select text?
0
 
ComputronAuthor Commented:
The users cannot select text
0
 
Robberbaron (robr)Commented:
to get it to scroll in reverse direction , i think you just set the scroll max as -1 , min as 5, small change as -1 .  Just a math issue as you guessed.

Background color : not able to change via VB. I suspect you will need to use API which is beyond me :-<

Problem with scrolling the RTF one line at a time is that the font size need not be consistent. If it is for you, i think you use the Heightof() function to calculate the height of text selected, then compare this to the height of the RTF box.   I used soemthing similar on a printout app i developed a while ago.
I will look tonight at my old code if no-one has better solution in meantime.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now