Click to See Complete Forum and Search --> : Add New line to multiline textbox


Cha0sBG
October 12th, 2009, 12:57 PM
Ok i've tryed to google it but not the results i need and not the right language so i'm gonna ask it here:

How to add a new line to a multiline textbot control in Win32 Visual C++.

And for example how to add the text to that textbox: Example

char Buffer = "a little buffer";
char Buffer2 = GetDlgItemText(......);

SetDlgItemText(hWnd, TXT1, Buffer + Buffer2);


that seems to be an incorrect way and i can't seem to find the correct one >.<

Any help will be useful.

hoxsiew
October 12th, 2009, 02:17 PM
You need to add a CR-LF pair for a new line in a multiline edit control. strcat() it to the first string, or make a third buffer with sprintf(). (Or use a string class like CString that supports "+" operator overloads).

_Superman_
October 12th, 2009, 03:59 PM
CString Buffer1 = _T("a little buffer");
CString Buffer2 = _T("another little buffer");

CString Buffer3 += _T("\r\n");
Buffer3 += Buffer2;

SetDlgItemText(hWnd, TXT1, Buffer3);

ovidiucucu
October 12th, 2009, 06:47 PM
First see How to append text to an edit control? (http://www.codeguru.com/forum/showthread.php?t=350435).
Also, as already suggested here, append a CR-LF ("\r\n") for a new line.