在richedit控件中,我想获得一行文本是否含有 \r\n字符,请问如何实现?这是我的代码:
LPTSTR szbuff;
m_richedit.GetLine(1,szbuff);
CString temp;
temp.Format("%s",szbuff);
if(temp.Find("\r\n"))
{
    执行其它代码......
}在控件中,我是想获得一行文本的字符数,用LineLength(int index)呢,只能找到第一行的字符数,下一行获得的还是这一行的字符数,所以我想用上面的方法,用LineIndex(int index)来获得字符数,只是要确定是否包含回车符!不知还是否有简单的方法?

解决方案 »

  1.   

    上一行为:
    if(temp.Find("\r\n")!=0)
      

  2.   

    将RichEdit设为多行的风格(multiple-line )应该就可以使用LineLength(int index)来查找某一行的字符数了。
      

  3.   

    并且找到的字符数都是第一行的字符数。
    下例:
    在控件中有9行字符
    int length[10];
    for(int   i=0;i<m_richedit.GetLineCount();i++)
    {
     length[i]=m_richedit.LineLength(i+1);
    }
    结果得出的数据都是一样的,都是第一行的字符数.
      

  4.   

    LineLength( int nLine = -1 ) nLine Specifies the character index of a character in the line whose length is to be retrievednline并不就是索引,你要调用LINEINDEX来获得。Use the LineIndex member function to retrieve a character index for a given line number within a multiple-line edit control.__________
    见MSDN。