Re: Multiline Edit control
Re: Multiline Edit control
Why don't you read MSDN?
Quote:
Text lines in a multiline control are separated by '\r\n' character sequences.
Re: Multiline Edit control
Re: Multiline Edit control
You mean to say that ..i will have to loop through the characters in the string
and insert \r whenever i encounter an '\n' .
Re: Multiline Edit control
You could do that (Although no looping is required, use CString::Replace()), but if you're reading the information from a file (I'm just guessing here, but it seems to be the case), then you might consider opening that file not in text mode but in binary mode. This way the \r\n (EOLN in Windows ASCII files) will not be substituted by \n when you read from the file.
Regards.
Re: Multiline Edit control
If you are reading text from a file, use CStdioFile::ReadString().
Quote:
The CString version of this function removes the '\n' if present; the LPTSTR version does not.
You should do something like this:
Code:
CStdioFile file;
CStirng strText = "";
if(file.Open("data.txt"))
{
CString strLine
while(file.ReadString(strLine))
strText += strLine + "\r\n";
file.Close();
}