I have been trying to create a new line in an Edit control. I used the sample code from Win32 - Appending text to an Edit Control with only a few small changes
To answer the question about multi-line, yes.
CreateWindow("EDIT","",WS_CHILD|WS_VISIBLE|ES_MULTILINE,
0,0,300,500,hwnd,(HMENU)1,inst,NULL);
Here is the edited code
// get edit control from dialog
HWND hwndOutput = GetDlgItem( hwnd, IDC_OUTPUT );
// get the current selection
DWORD StartPos, EndPos;
SendMessage( hwndOutput, EM_GETSEL, reinterpret_cast<WPARAM>(&StartPos), reinterpret_cast<WPARAM>(&EndPos) );
// move the caret to the end of the text
int outLength = GetWindowTextLength( hwndOutput );
SendMessage( hwndOutput, EM_SETSEL, outLength, outLength );
//INSERTED CODE INSERTED CODE INSERTED CODE INSERTED CODE INSERTED CODE
// insert newline
SendMessage( hwndOutput, EM_REPLACESEL, TRUE, reinterpret_cast<LPARAM>((TCHAR*)"\n\r") );
int outLength = GetWindowTextLength( hwndOutput );
SendMessage( hwndOutput, EM_SETSEL, outLength, outLength );
//INSERTED CODE INSERTED CODE INSERTED CODE INSERTED CODE INSERTED CODE
// insert the text at the new caret position
SendMessage( hwndOutput, EM_REPLACESEL, TRUE, reinterpret_cast<LPARAM>(newText) );
// restore the previous selection
SendMessage( hwndOutput, EM_SETSEL, StartPos, EndPos );
The text is appending as expected, but there is still no newline. What am I missing?