Results 1 to 8 of 8

Thread: text box annoyance

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    This is what happens:
    say this is the chat log:

    -
    Me: hey
    you: sup?
    me: Nothing much, you?
    you: same
    -
    me: sounds fun
    you: indeed...
    me: well my textbox glitches

    Ok, that's all nice, say the height is only 4 lines high
    but when I add text and I have the selstart = len(text) it'll flash to the top of the box so I can very briefly see the top 4 lines then it goes to the bottom. I havn't experienced this with other programs, aol, etc.

    I need something to make the scroll bar stay in the same place.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The reason for this flicker is that you are changing the Text property. When you do that the caret is moved to the first position in the TextBox. Use the SelText property instead:
    Code:
    With RichTextBox1
        .SelStart = Len(.Text)
        .SelText = vbCrLf & "The New Text To Add"
    End With
    Good luck!

  3. #3

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Your code worked great except that the SelText blocks some characters. Chr$(0) for example, if anything comes after it it won't appear.

    Anyway to fix this?

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The reason chr$(0) is blocked is because in C and C++ a null char means end of string.

    Why would you like to send a null char after all?

  5. #5

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    It has a coloring code like IRC where the first few characters format the text, bold, italic, colors, etc.

  6. #6

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Further more...
    That's why I switched to a RTB instead of a regular textbox.

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Use the SelColor, SelBold, SelItalic, SelUnderline and so on to set these properties before you use the SelText property to set the text.
    Code:
    With RichTextBox1
        .SelStart = Len(.Text)
        .SelColor = vbRed 'or whatever
        .SelBold = True
        .SelText = "Here comes some text in red and bold font"
    End With
    Good luck!

  8. #8
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196
    I'm not sure if this will work, i havn't tried it on a rtbox, but it got rid of glitches in a flexgrid control.

    before you assign the new text to the rich text box can you just set the visible property of the box to false, and then set it to true after you add the text?

    maybe maybe who knows...


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