Condividi tramite


CEdit::LineLength

Retrieves the length of a line in an edit control.

int LineLength(
   int nLine = -1 
) const;

Parameters

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

Return Value

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.

Remarks

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

Example

See the example for CEdit::LineIndex.

Requirements

Header: afxwin.h

See Also

Reference

CEdit Class

Hierarchy Chart

CEdit::LineIndex

EM_LINELENGTH

Other Resources

CEdit Members