Windows Develop Bookmark and Share   
 index > Windows Forms General > Using EM_GETLINE
 

Using EM_GETLINE

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() );
}
Matthew Vukomanovic  Friday, July 20, 2007 5:25 AM
Sorry searching a bit more i found the following post
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=30372&SiteID=1
where there is a working solution
Matthew Vukomanovic  Friday, July 20, 2007 6:17 AM
Sorry searching a bit more i found the following post
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=30372&SiteID=1
where there is a working solution
Matthew Vukomanovic  Friday, July 20, 2007 6:17 AM

You can use google to search for other answers

Custom Search

More Threads

• .NET SaveFileDialog - extension not added
• Settings and their data types in .NET
• double click on grid row.
• printing rotated text
• Display rss in a tool bar
• Globalization and Cultures
• MDI in Whidbey
• ListView Grouping
• combobox property
• adding item to combo box