Hi,
I found the post
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=448039&SiteID=1 which seemed to fix the problem for that guy.
I want to call SendMessageA on a text box getting back the contents of a line.
I need to use this and not textbox.Lines since the line number i'm getting back (and need to use) is the lines in the display not the lines sepereated by line feeds.
I'm using VS.2005 Framework 2
The following code is from a form with a textbox (textbox1) and a button (btnGetText)
on the button click then the text should be gotten of the first line of the textbox.
The code is basically copied from the other post.
I'm not getting an error when i run this is just doesn't return anything in the buffer.
Anyone have any ideas on what i could be doing wrong?
[DllImport( "user32.dll", EntryPoint = "SendMessageA" )]
private static extern int SendMessage_Ex
( IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam );
private const int EM_GETLINE = 0xc4;
public FormTextBoxTest()
{
InitializeComponent();
}
private void btnGetText_Click( object sender, EventArgs e )
{
StringBuilder buffer = new StringBuilder( 256 );
SendMessage_Ex( textBox1.Handle, EM_GETLINE, 0, buffer );
MessageBox.Show( buffer.ToString() );
}