Archived

This topic is now archived and is closed to further replies.

LordN

Edit Boxes

Recommended Posts

I have a program which contains two edit boxes. The first edit box is a single line and the other is a multiline. When the user presses enter, the text entered in the single box is saved to a string. However, I can not figure out how to make it so that when enter is pressed, the text entered in the single line box appears in the multiline box, and then the next time enter is pressed the new text is entered into the second box a line down from the original text.

Share this post


Link to post
Share on other sites
Plain win32 calls or MFC?

I know little of MFC, but I can make some guesses with win32 code. I'm guessing that, if you append a newline character followed by the string you want to add, it'll appear as a new line.
One way to do this is to read the entire text of the textbox (with WM_GETTEXTLENGTH followed by WM_GETTEXT), append the newline character and your string, then use WM_SETTEXT to write it back to the textbox.
Another might be to get the length of the textbox (WM_GETTEXTLENGTH), set the selection range to the end of the textbox (EM_SETSEL), then use EM_REPLACESEL to append a newline and your string.

Hopefully these'll work out.

EDIT: I've tested them; it seems that two characters ("\r\n") are necessary to indicate a line break.

[edited by - Beer Hunter on July 26, 2003 6:09:59 AM]

Share this post


Link to post
Share on other sites