CRichEditCtrl::LineFromChar

检索包含指定的字符的索引行的行号。

long LineFromChar(
   long nIndex 
) const;

参数

  • nIndex
    在编辑控件的文本包含所需字符的从零开始的索引值或包含– 1。 如果 nIndex 为– 1,它指定当前行,即,一个包含插入符号的行。

返回值

包含字符的索引的行的从零开始的行号指定 nIndex。 如果 nIndex 为– 1,包含选定内容的第一行字符数返回。 如果未选择,当前行号返回。

备注

字符的索引是字符数从最初rich edit控件。 对于字符数,OLE项计数为单个字符。

有关更多信息,请参见 Windows SDK的 EM_EXLINEFROMCHAR

示例

// The index of the char to get information on.
int nIndex = 11;

CString strText;

m_myRichEditCtrl.GetWindowText(strText);
strText = strText.Mid(nIndex, 1);

// Dump the index, character and line number.
TRACE(_T("nIndex = %d, character = %c, line = %d\r\n"),
   nIndex, strText[0], m_myRichEditCtrl.LineFromChar(nIndex));   

要求

Header: afxcmn.h

请参见

参考

CRichEditCtrl选件类

层次结构图

CRichEditCtrl::GetLineCount

CRichEditCtrl::GetLine

CRichEditCtrl::LineIndex