CString Problerm
-
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!