954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

New Lines in Visual C++ Multiline Edit Boxes?

I have an edit box, with its settings as "multiline", "want return", and "vertical scroll."
All I want to do is to have new lines between each output line. However, I have tried "\n", which did not work. So, is there a way to make them have line breaks?

ilikerps
Light Poster
45 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

Mdos uses one character to represent a newline ascii character number 10.
Windows app's however use two characters to represent a newline, ascii characters numbers 13 and 10.

In a multline control to get a newline you have to use char(13) followed by char(10)

freespace
Newbie Poster
5 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

Hmm.... I tried this:

m_ChatText = "Hello!";
	MessageBox(m_ChatText);
	m_ChatText += char(13) + char(10);
	MessageBox(m_ChatText);
	m_ChatText += "How are you?";
         MessageBox(m_ChatText);

The output is:Hello!
Hello!|-
Hello!|-How are you?

Carriage return, line feed does make sense but it isn't working, at least not how I am implementing it in the above.

So I tried using both escape sequences /r/n which does make a newline.

ilikerps
Light Poster
45 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

m_ChatText += char(13) + char(10);
might not work as expected.
the compiler sees char(13) + char(10) like 13 + 10 = 23

So its like writing m_ChatText += char(23);

freespace
Newbie Poster
5 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You