Jump to content

  • Log In with Google      Sign In   
  • Create Account


Win32 Edit Control Help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Kevn   Members   -  Reputation: 163

Like
0Likes
Like

Posted 06 December 2012 - 01:10 AM

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?

Sponsor:

#2 Endurion   Crossbones+   -  Reputation: 3387

Like
3Likes
Like

Posted 06 December 2012 - 01:55 AM

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>

#3 Kevn   Members   -  Reputation: 163

Like
0Likes
Like

Posted 06 December 2012 - 03:26 AM

Awesome, thank you for the help.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS