CString Problerm
-
Hi A famous Newbies example to declare a CString was CString welcome_string = "Welcome to Visual C++"; What if I want to declare a text that was as long as one paragraph? when I can't even do things like this CString welcome_string ="Welcome to Visual C++...not finish yet continue next line .....more text "; there was a "newline is constant" error. Please help X| Newbies
-
Hi A famous Newbies example to declare a CString was CString welcome_string = "Welcome to Visual C++"; What if I want to declare a text that was as long as one paragraph? when I can't even do things like this CString welcome_string ="Welcome to Visual C++...not finish yet continue next line .....more text "; there was a "newline is constant" error. Please help X| Newbies
-
Hi A famous Newbies example to declare a CString was CString welcome_string = "Welcome to Visual C++"; What if I want to declare a text that was as long as one paragraph? when I can't even do things like this CString welcome_string ="Welcome to Visual C++...not finish yet continue next line .....more text "; there was a "newline is constant" error. Please help X| Newbies
this is easy: CString t= "hello \ world"; Pay attention to the backslash, type ENTER after it and go on
-
this is easy: CString t= "hello \ world"; Pay attention to the backslash, type ENTER after it and go on
or you can do this CString t = "Hello" "World"; without the '\' slash character
-
you need a "\" as this: CString welcome_string ="Welcome to Visual C++...not finish yet continue next line\ .....more text "; to let the compiler know that this line is not finished. try it.
-
Thanks. I never thought it was so simple. What a shame. What if I want to force it to make a newline? Newbies
-
A new line in the text? Use
\n
, there's others too like\t
for tab,\\
for '\', etc. Look these up (or 'escape sequences') in MSDN for more info
Dylan Kenneally London, UK
-
Thanks I've look at MSDN and you were right. but when I want to type like this CString welcome_string = "Hello\ \n World"; so that Hello and World are in different line, there was a "newline is constant" error. :confused: Newbies
-
lucy wrote: CString welcome_string = "Hello\ \n\ World"; Thanks again. I've tried that but this came out warning C4129: ' ' : unrecognized character escape sequence and the line was still in one line. :confused: Newbies
-
A lot of thanks for your reply:) BUT the output was Hello|World and not Hello World this was my code
void CMyView::OnDraw(CDC* pDC) { CString welcome_string = "Hello\n\ World"; pDC->TextOut(0,0,welcome_string); }
Newbies -
Thanks:rose: Is this means only messagebox can handle "\n"? How about editbox or listbox ia a dialog? Newbies
-
I'm afraid TextOut couldn't handle the "\n", but MessageBox() can. Try MessageBox(welcome_string); and see.
-
A lot of thanks for your reply:) BUT the output was Hello|World and not Hello World this was my code
void CMyView::OnDraw(CDC* pDC) { CString welcome_string = "Hello\n\ World"; pDC->TextOut(0,0,welcome_string); }
NewbiesAs Lucy said,
TextOut()
can not handle newlines, but DrawText() can. If you want to output multi line text useDrawText()
. HTH
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!