Win32 Edit Control Help

Started by
1 comment, last by Kevn 11 years, 4 months ago
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?
Advertisement
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Awesome, thank you for the help.

This topic is closed to new replies.

Advertisement