Sign in to follow this  
Kevn

Win32 Edit Control Help

Recommended Posts

Kevn    166
I am working on a chat portion of a program and I am using two edit control windows and one button for the chat. One edit control window(lets call it chat window) is read only and is where all the text in the chat is displayed. The other edit control window(input window) is where the user inputs text to the chat window. The button(send) takes the text from the input window and adds it onto a string containing the text in the chat window and then updates the chat window text with that string. Now that works fine for placing the text in the chat window.However, when the string length in the chat window is greater than the window size and the scroll bar becomes active, if new text is inputed to the chat window, the scroll bar resets to the top position instead of staying scrolled all the way down. This is problematic because if two users are typing to eachother, they will have to continuely scroll down whenever something new is said to see it.
So my question is, how would I go about fixing this or is there a better way to make the chat window portion then using an edit control window?

Share this post


Link to post
Share on other sites
Endurion    5408
Stolen from StackOverflow:

Better than using SetWindowText to replace the full text:
You can add text by setting the beginning and end of the selection to the end of the text in the control (EM_SETSEL), then replacing the (empty) selection with your new text (EM_REPLACESEL).

Scrolling to the bottom can be done with EM_SCROLLCARET after the caret (the selection) is at the end of the text. There are other ways, but if you're doing it immediately after adding text, this is probably the easiest.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this