[VB.NET] Using SendMessage and EM_GETLINE

B

Brian

I used SendMessage to get the line count of a multiline textbox, since it
recognizes word wrap as a new line (and not only crlf). But with EM_GETLINE
it needs a pointer to a buffer for the lparam. How do I do this?
 
K

Ken Tucker [MVP]

Hi,


Why not use the lines property instead of sendmessage?

Trace.WriteLine(TextBox1.Lines.GetUpperBound(0))



Ken
 
B

Brian

Well, Lines says I only have one line cause there aren't any crlf's. But I
want to go by word wrapping.. so the first line before the first word wrap.
And EM_GETLINECOUNT detects word wraps and counts them as lines, even though
all I really have is one long line word wrapped in a textbox that isn't wide
enough. Since EM_GETLINECOUNT detect the number of lines like i wanted, I
assumed that EM_GETLINE would work the same way, and get a line based on
word wrap.
 
K

Ken Tucker [MVP]

Hi,

Const EM_GETLINECOUNT As Integer = &HBA



Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, _

ByVal lParam As Integer) As Integer



Trace.WriteLine(SendMessage(TextBox1.Handle, EM_GETLINECOUNT, 0, 0))



Ken

-------------------------

Well, Lines says I only have one line cause there aren't any crlf's. But I
want to go by word wrapping.. so the first line before the first word wrap.
And EM_GETLINECOUNT detects word wraps and counts them as lines, even though
all I really have is one long line word wrapped in a textbox that isn't wide
enough. Since EM_GETLINECOUNT detect the number of lines like i wanted, I
assumed that EM_GETLINE would work the same way, and get a line based on
word wrap.
 
B

Brian

Hi Ken, I really appreciate the help, but like I said I've used
EM_GETLINECOUNT to get the line count already, and that works fine. I need
help with EM_GETLINE, which get's a line of text and stores it in a byte
array. For EM_GETLINE, SendMessage requires a pointer to a byte array for
lparam. How do I accomplish this? Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top