
rich text box, remembering view / position of scroll bars
Is there a way to retrieve a position on the scroll bar ?
I'm trying to do something like this....
RememberSelStart = .SelStart ' works fine
RememberSelLength = .SelLength ' works fine
RememberScrollBar = .ScrollBarPosition ' <--(grasping at straws here)
'<HERE IS THE ROUTINE THAT READS THROUGH THE TEXT FILE>
' NOW RESET THE DISPLAY SO USER DOESN'T SEE ANY CHANGE
.SelStart = RememberSelStart ' this works fine
.SelLength = RememberSelLength ' this works fine
.ScrollBarPosition = RememberScrollBar ' <-- need this to work
I can manage to get it to remember the selection, but my scroll bar view
keeps getting messed up...
my real code is below (above is an abbreviated version)... This code color
all HTML tags blue <in brackets = blue> the rest black <blue> black
<blue>
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
Long) As Long
Public Sub SetTextColors()
Dim Spot1 As Long
Dim Spot2 As Long
Dim TempSelStart As Long
Dim TempSelLength As Long
TempSelLength = RichTextBox1.SelLength
TempSelStart = RichTextBox1.SelStart
LockWindowUpdate RichTextBox1.hWnd: Screen.MousePointer = vbHourglass
Spot1 = 1
Spot2 = 1
With RichTextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = vbBlack
Do While Spot1 > 0
DoEvents
Spot1 = InStr(Spot1, .Text, "<")
If Spot1 > 0 Then
.SelStart = Spot1
.SelLength = 1
Spot2 = InStr(Spot1, .Text, ">")
If Spot2 = 0 Then Spot2 = Len(.Text)
ColorCharacter Spot1, Spot2, vbBlue
Spot1 = Spot2 + 1
End If
Loop
.SelStart = TempSelStart
.SelLength = TempSelLength
End With
LockWindowUpdate 0&: Screen.MousePointer = vbNormal
End Sub
Public Sub ColorCharacter(Spot1, Spot2, TextColor)
RichTextBox1.SelStart = Spot1 - 1
RichTextBox1.SelLength = (Spot2 + 1) - Spot1
RichTextBox1.SelColor = TextColor
End Sub