DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   New Lines in Visual C++ Multiline Edit Boxes? (http://www.daniweb.com/forums/thread38315.html)

ilikerps Jan 18th, 2006 7:06 pm
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?

freespace Jan 20th, 2006 4:44 pm
Re: New Lines in Visual C++ Multiline Edit Boxes?
 
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)

ilikerps Jan 20th, 2006 8:17 pm
Re: New Lines in Visual C++ Multiline Edit Boxes?
 
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.

freespace Jan 20th, 2006 11:49 pm
Re: New Lines in Visual C++ Multiline Edit Boxes?
 
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);


All times are GMT -4. The time now is 6:19 am.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC