-
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. :)
-
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
-
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.
-
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 :(
-
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. :rolleyes:
-
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.
-
Ohhhhh! :rolleyes:
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
-
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 - 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]
-
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. :rolleyes:
-
Hrm... Thanks for the ideas. I'll keep trouble-shooting.
-
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?
-
MaxLength will cut off characters. Not good if you have more text flowing in.