Results 1 to 13 of 13

Thread: A question about text boxes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16

    Question

    I've created a simple Telnet application. The only problem is that the text is filled into an array and placed into a text box. When it receives the data, its stuffs it into the array, and then pushes that array into the text box. The cursor is then pushed down to the bottom of the text (so it appears as if the text is filling in at the bottom line). This makes it pretty jumpy after about 80 lines of text roll through.

    Is there any way that I can perfect this so that I don't get the jumpiness? Is there perhaps a way to make the textbox fill from the bottom up, instead of vice versa? Thanks for your help.
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What do you mean by jumpy? Why from bottom up, that would look pretty stupid, the textbox should add text to the bottom as it does in telnet
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16
    The problem is when the program runs. When the Winsock control gets the data, it posts it to the text box on my form. In order to scroll to the bottom automatically, I have to use the command:
    Code:
    TxtIncoming.SelStart = Len(TxtIncoming.Text)
    This is what makes it jumpy, since every time the textbox receives new data it moves the cursor to the top.
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Can't you just save the old position?
    like

    Code:
    Dim oPos% 'or make it long depending on the length of the text
    
    oPos = TxtIncoming.SelStart
    TxtIncoming.SelStart = Len(TxtIncoming.Text)
    TxtIncoming.SelStart = oPos

    <jop edit's>
    ... oh wait this isn't making sense I think huh?
    how many lines fit on the textbox??? maybe delete 10 from it or so.

    dunnu though

    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Use this to make it from the bottom up:
    Code:
    ' To add text, use this:
    txtIncoming.SelStart = 0 ' Make sure the caret is in the beginning
    txtIncoming.SelText = "This is added to the beginning." & vbNewLine
    txtIncoming.SelStart = 0 ' Put the caret in the beginning
    Your jumpiness problems are solved.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16
    Hrm... Not really what I was looking for. The textbox has no limit to the lines, but I built an array of 75 lines of data. Thanks, though, Jop.

    Yonatan, I probably made myself unclear before. The text needs to fill in at the bottom. Every time text is put in the textbox, it automatically resets the caret to the top of the text box. I then have to force it to the bottom. I was just wondering if I could somehow override that, so the caret would stay at the bottom, no matter what.
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

  7. #7
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Ohhhhh!
    In that case, try this:
    Code:
    txtIncoming.SelStart = Len(txtIncoming.Text) ' Put the caret at the end
    txtIncoming.SelText = "This is added to the end, and doesn't jump or anything!" & vbNewLine

  8. #8
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986

    so the caret would stay at the bottom, no matter what.

    hmm can't you just put this in your form?
    Code:
    Private Sub Text1_Change()
    Text1.SelStart = Len(Text1) '?
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16
    Jop - that was what I was doing, that that is what makes the text box jumpy. Every time text is added the caret jumps to the top, and then you have to move it to the bottom. When the server sends a lot of data, it fills the textbox and then the cursor jumps to the bottom, which makes it appear jumpy.

    Yonatan - That's still not doing it.

    Hehe, I started this project a while back and gave up on it because of this... Thanks for your help, hopefully we can get an answer to this.

    [Edited by Ravyn on 11-01-2000 at 09:56 AM]
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

  10. #10
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    If it is bad when you receive a lot of text from the server, then try temporarily locking the TextBox.
    Code:
    ' General declaration:
    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long
    
    ' To add lots of data:
    Call LockWindowUpdate(txtIncoming.hWnd)
    txtIncoming.SelStart = Len(txtIncoming.Text)
    txtIncoming.SelText = "Lots of data goes here" & vbNewLine
    Call LockWindowUpdate(0)
    Hopefully this won't make it worse or anything.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16
    Hrm... Thanks for the ideas. I'll keep trouble-shooting.
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

  12. #12
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    LockWindowUpdate?¿
    The LockWindowUpdate function disables drawing in the given window. Only one window can be locked at a time.

    I think that's a bit to drastic for blocking text just assign a number to the txtIcoming.maxLength and you're done?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Posts
    16
    MaxLength will cut off characters. Not good if you have more text flowing in.
    - Jason Egan
    Entry-level programmer, VB Lover
    VB6 Enterprise Edition SP3
    http://jeprod.cjb.net/

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