|
-
May 10th, 2005, 04:27 AM
#1
Multiline Edit control
In Multiline Edit control ..when i set the text which contains
'\n' character using the SetWindowText function ,it's not
moved onto the next line ,but instead it displays a thick line for
the '\n' and all the characters are displayed in the same line.
How can i display the text onto the next line ..if the string
contains a '\n' character in Multiline Editcontrol.
-
May 10th, 2005, 04:30 AM
#2
Re: Multiline Edit control
-
May 10th, 2005, 05:35 AM
#3
Re: Multiline Edit control
Why don't you read MSDN?
Text lines in a multiline control are separated by '\r\n' character sequences.
-
May 10th, 2005, 05:43 AM
#4
Re: Multiline Edit control
-
May 10th, 2005, 07:43 AM
#5
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' .
-
May 10th, 2005, 07:53 AM
#6
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.
-
May 10th, 2005, 09:12 AM
#7
Re: Multiline Edit control
If you are reading text from a file, use CStdioFile::ReadString().
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();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|