I am facing a very strange problem and couldn’t figure out where’s the mistake. I’m using SendMessage_EX to get a specified line’s text:
SendMessage_Ex(hr.Handle, EM_GETLINE, l, buffer);
then I call the method twice like this:
StringBuilder buffer = new StringBuilder(256);
SendMessage_Ex(hr.Handle, EM_GETLINE, 5, buffer);
StringBuilder buffer1 = new StringBuilder(256);
SendMessage_Ex(hr.Handle, EM_GETLINE, 4, buffer1);
It gets text of line 5 correctly but then for line 4, It returns nothing(buffer1 is empty).
If I reverse it and first get line 4 and then line 5, It returns the text of line 4 and nothing for line 5.
It’s very strange and I’m sure I’m making a simple mistake, but where is the mistake?
I appreciate any help. 🙂
The EM_GETLINE message wants the size of the buffer passed in the same parameter it uses for a buffer. I couldn’t just set the 0 index of the StringBuilder without initializing it to some value (got an index exception).
This seems to work: