We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

CEdit::LineLength

Updated: September 2008

Retrieves the length of a line in an edit control.

int LineLength(
   int nLine = -1 
) const;

nLine

The zero-based index of a character in the line whose length is to be retrieved. The default value is -1.

For single-line edit controls, the return value is the length, in TCHARs, of the text in the edit control.

For multiline edit controls, the return value is the length, in TCHARs, of the line specified by the nLine parameter. For ANSI text, the length is the number of bytes in the line; for Unicode text, the length is the number of characters in the line. The length does not include the carriage-return character at the end of the line.

If the nLine parameter is more than the number of characters in the control, the return value is zero.

If the nLine parameter is –1, the return value is the number of unselected characters in the lines that contain selected characters. For example, if the selection extends from the fourth character of one line through the eighth character from the end of the next line, the return value is 10. That is, three characters on the first line and seven on the next.

For more information about the TCHAR type, see the TCHAR row in the table in Windows Data Types.

This method is supported by the EM_LINELENGTH message, which is described in the Windows SDK.

See the example for CEdit::LineIndex.

Header: afxwin.h

Date

History

Reason

September 2008

Revised the parameters and return value sections to be consistent with the Windows SDK description.

Customer feedback.

Show: