Results 1 to 27 of 27

Thread: [RESOLVED] Capture Scroll Event of RichTextBox

Threaded View

  1. #21
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: [RESOLVED] Capture Scroll Event of RichTextBox

    Here is a better looking separator routine.
    The beauty of this routine is that it inserts a seperator that looks nice, scrolls properly and the user cannot access. The one problem is that you will have to remove it before saving, but that is easily handled with a call to replace.

    Use the above (fixed) colortable function and this new separator routine
    VB Code:
    1. Public Sub Separator(rtb As RichTextBox, lColor1 As Long, _
    2.     lColor2 As Long, halfWidth As Integer, txtTitle As String)
    3.     Dim iPos As Long
    4.     Dim strRTF As String
    5.     Dim txtTemp As String
    6.     Dim icolor1 As Integer
    7.     Dim icolor2 As Integer
    8.     Dim iUP As Integer
    9.     With rtb
    10.         iPos = .SelStart
    11.         iUP = Int(.SelFontSize) - 1
    12.         'bracket selection
    13.         .SelText = Chr(&H80) & .SelText & Chr(&H81) ' \'80 \'81
    14.         strRTF = rtb.TextRTF
    15. 'add new colors
    16.         icolor1 = AddColorToTable(strRTF, lColor1)
    17.         icolor2 = AddColorToTable(strRTF, lColor2)
    18. 'add separator
    19.  
    20.         txtTemp = "\par" & _
    21.          "\cf" & CStr(icolor1) & "\protect\up" & CStr(iUP) & " " & String(halfWidth, "_") & "\up0" & _
    22.          "\cf" & CStr(icolor2) & " " & txtTitle & _
    23.          "\cf" & CStr(icolor1) & "\up" & CStr(iUP) & " " & String(halfWidth, "_") & "\up0\cf0"
    24.  
    25.          strRTF = Replace(strRTF, "\'80", txtTemp)
    26.          strRTF = Replace(strRTF, "\'81", "\protect0\cf0\par  ")
    27.  
    28.          .TextRTF = strRTF
    29.         .SelStart = iPos
    30.        End With
    31. End Sub
    Just call it like this
    VB Code:
    1. Separator rtb, vbRed, vbBlue, 20, " Visual Basic Code "
    Last edited by moeur; Aug 3rd, 2005 at 07:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width