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:
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:
StringBuilder buffer = new StringBuilder(" ", 256);
buffer[0] = (char)256;
int Result = SendMessage_Ex(textBox1.Handle, EM_GETLINE, 3, buffer);
StringBuilder buffer1 = new StringBuilder(" ", 256);
buffer1[0] = (char)256;
int Result1 = SendMessage_Ex(textBox1.Handle, EM_GETLINE, 2, buffer1);
MessageBox.Show(buffer.ToString());
MessageBox.Show(buffer1.ToString());