The weirdness of EM_GETLINE

Source: Internet
Author: User
It was a waste of half a day because it didn't take a good look at the MSDN comments...

It seems that it is true that the server is not cut by mistake ..

SendMessage (

(HWND) hWnd, // handle to destination window

EM_GETLINE, // message to send

(WPARAM) wParam, // line number

(LPARAM) lParam // line buffer (LPCTSTR)




Specifies the zero-based index of the line to retrieve from a multiline edit control. A value of zero specifies the topmost line. This parameter is ignored by a single-line edit control.


Pointer to the buffer that records es a copy of the line. before sending the message, set the first word of this buffer to the size, in TCHARs, of the buffer. for ANSI text, this is the number of bytes; for Unicode text, this is the number of characters. the size in the first word is overwritten by the copied line.

Return Values

The return value is the number of TCHARs copied. The return value is zero if the line number specified by the wParam parameter is greater than the number of lines in the edit control.


Edit controls: The copied line doesNotContain a terminating null character.

So we need to call it like this:

* (LPWORD) gBuf) = MAX_GBUF;

Int nLen = SendMessage (hWnd, EM_GETLINE, nLine, (LPARAM) gBuf );

GBuf [nLen] = '\ 0 ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.