rich text box, remembering view / position of scroll bars 
Author Message
 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



Tue, 25 Oct 2005 03:31:02 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help with scrolling rich/text box to a position using button

2. Rich Text Box & scroll bar

3. Rich text box & scroll bar

4. Run-time control of rich text box scroll bar visibility

5. Rich Text Box Control Scroll Bars

6. Rich text box & scroll bar

7. Rich Text Box Horiziontal Scroll Bar Problem

8. Scroll Bars in a Rich Text Box

9. Rich Text Box Scroll Bars

10. Rich Text Box vs. Text Box Scrolling

11. Controling the position of text in a Rich Text Box

12. Positioning text to specific locations in a rich text box

 

 
Powered by phpBB® Forum Software