CRichEditCtrl::LineIndex
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

CRichEditCtrl::LineIndex 

Retrieves the character index of a line within this CRichEditCtrl object.


int LineIndex(
   int nLine = -1 
) const;

Parameters

nLine

Contains the index value for the desired line in the text of the edit control, or contains –1. If nLine is –1, it specifies the current line, that is, the line that contains the caret.

The character index of the line specified in nLine or –1 if the specified line number is greater then the number of lines in the edit control.

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 Platform SDK.

// The pointer to my rich edit control.
extern CRichEditCtrl* pmyRichEditCtrl;
// The string for replacing.
extern LPCTSTR lpszmyString;

int nBegin, nEnd;

// Replace the second line, if it exists, of the rich edit control
// with the text lpszmyString.
if ((nBegin=pmyRichEditCtrl->LineIndex(1)) != -1)
{
   nEnd = nBegin + pmyRichEditCtrl->LineLength(1); 
   pmyRichEditCtrl->SetSel(nBegin, nEnd);
   pmyRichEditCtrl->ReplaceSel(lpszmyString);
}
Show:
© 2016 Microsoft