Re: Textbox
- Posted by Derek Parnell <ddparnell at bigpond.com> Jan 27, 2002
- 391 views
>----- Original Message ----- >From: PETER at pmullen.fsnet.co.uk >To: EUforum >Sent: Monday, January 28, 2002 7:33 AM >Subject: Textbox > > > >Hi i am currently working on a network text program and >Im using a textbox to recive the text but I Cant seem >to get the cursor to move to the next line when a new >message is recived, Can nayone give me code, examples >to help Hi, firstly, I'm assuming you are using win32lib. There is a routine in win32lib called setSelectedText() that can help you. It is designed to replace any selected text with the new text that you provide. The trick is to move the cursor to the end of the current text and "select" the end-of-text before using this routine. Here is some sample code for that... integer lLength -- Get the length of any existing text lLength = sendMessage( msgarea, WM_GETTEXTLENGTH, 0, 0 ) -- Move the cursor to the end of the text. setIndex(msgarea, lLength+1) -- Append the new text, including a CR and LF setSelectedText(msgarea, newtext & 13 & 10) This works if the msgarea is created as a MleText control rather than an EditText control. However, in testing this code, I found a bug in the win32lib file. To fix this, you need to find the setSelectedText procedure and the line ... if lo_word(result)<hi_word(result) then then change the "<" to "<=" which should result in the fixed line ... if lo_word(result)<=hi_word(result) then Another cosideration is that there is a limit to how much text a MleText control can hold. It might be better to use a RichEdit control if you need more than 65,000 characters in the message area. --------- Derek.