|
-
Oct 31st, 2000, 09:50 PM
#1
Thread Starter
Junior Member
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.
-
Nov 1st, 2000, 12:09 AM
#2
transcendental analytic
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.
-
Nov 1st, 2000, 09:24 AM
#3
Thread Starter
Junior Member
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.
-
Nov 1st, 2000, 09:34 AM
#4
Frenzied Member
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.
-
Nov 1st, 2000, 09:37 AM
#5
Guru
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.
-
Nov 1st, 2000, 09:43 AM
#6
Thread Starter
Junior Member
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.
-
Nov 1st, 2000, 09:48 AM
#7
Guru
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
-
Nov 1st, 2000, 09:49 AM
#8
Frenzied Member
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.
-
Nov 1st, 2000, 09:54 AM
#9
Thread Starter
Junior Member
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]
-
Nov 1st, 2000, 10:58 AM
#10
Guru
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.
-
Nov 1st, 2000, 11:02 AM
#11
Thread Starter
Junior Member
Hrm... Thanks for the ideas. I'll keep trouble-shooting.
-
Nov 1st, 2000, 11:07 AM
#12
Frenzied Member
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.
-
Nov 1st, 2000, 11:17 AM
#13
Thread Starter
Junior Member
MaxLength will cut off characters. Not good if you have more text flowing in.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|