CRichEditCtrl::LineIndex
Visual Studio 2012
Retrieves the character index of a line within this CRichEditCtrl object.
int LineIndex( int nLine = -1 ) const;
The character index is the number of characters from the beginning of the rich edit control to the specified line.
For more information, see EM_LINEINDEX in the Windows SDK.
// The string for replacing. LPCTSTR lpszmyString = _T("Hello, I'm the new second line."); int nBegin, nEnd, nIndex; // Replace the second line, if it exists, of the rich edit control // with the text lpszmyString. nIndex = m_myRichEditCtrl.LineIndex(1); if ((nBegin = nIndex) != -1) { nEnd = nBegin + m_myRichEditCtrl.LineLength(nIndex); m_myRichEditCtrl.SetSel(nBegin, nEnd); m_myRichEditCtrl.ReplaceSel(lpszmyString); }