The EM_LINELENGTH message retrieves the length, in characters, of a line in an edit control. You can send this message to either an edit control or a rich edit control.
To send this message, call the SendMessage function with the following parameters.
(HWND) hWnd, // handle to destination window
EM_LINELENGTH, // message to send
(WPARAM) wParam, // character index
(LPARAM) lParam // not used; must be zero
Specifies the character index of a character in the line whose length is to be retrieved. If this parameter is greater than the number of characters in the control, the return value is zero.
This parameter can be 1. In this case, the message returns the number of unselected characters on lines containing selected characters. For example, if the selection extended from the fourth character of one line through the eighth character from the end of the next line, the return value would be 10 (three characters on the first line and seven on the next).
This parameter is not used.
For multiline edit controls, the return value is the length, in TCHARs, of the line specified by the wParam parameter. For ANSI text, this is the number of bytes; for Unicode text, this is the number of characters. It does not include the carriage-return character at the end of the line.
For single-line edit controls, the return value is the length, in TCHARs, of the text in the edit control.
If wParam is greater than the number of characters in the control, the return value is zero.
Use the EM_LINEINDEX message to retrieve a character index for a given line number within a multiline edit control.