473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

VS 2005 and EM_GETLINECOUNT

Hi, can someone help me with this? I use VB.NET and are trying to the
EM_GETLINECOUNT to count lines in a textbox. But all examples that i have
found has to problemes. as any cant be used in VS2005 and hwnd or handle,
but i cant get the textbox.hwnd og handle to work. I always get error that
hwnd or handle is not a member of system.web.ui.webcontrols.

I want a code that can read how many lines that are in use in a textbox that
are multiline and wrap enabled.

/Per W.
Nov 19 '06 #1
3 3132
On Sun, 19 Nov 2006 11:28:24 +0100, Per W. wrote:
Hi, can someone help me with this? I use VB.NET and are trying to the
EM_GETLINECOUNT to count lines in a textbox. But all examples that i have
found has to problemes. as any cant be used in VS2005 and hwnd or handle,
but i cant get the textbox.hwnd og handle to work. I always get error that
hwnd or handle is not a member of system.web.ui.webcontrols.

I want a code that can read how many lines that are in use in a textbox that
are multiline and wrap enabled.

/Per W.
Option Strict On

Public Class Form1

Private Const EM_GETLINECOUNT As Integer = &HBA
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"_
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,_
ByVal lParam As Integer) As Integer

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Ret As Integer
Ret = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT, 0, 0)
TextBox1.Height = (Ret + 1) * TextBox1.Font.Height
End Sub
End Class

Cheers,
Gadget
Nov 19 '06 #2

"Gadget" <ga****@sobell.netskrev i melding
news:o6*****************************@40tude.net...
On Sun, 19 Nov 2006 11:28:24 +0100, Per W. wrote:
>Hi, can someone help me with this? I use VB.NET and are trying to the
EM_GETLINECOUNT to count lines in a textbox. But all examples that i have
found has to problemes. as any cant be used in VS2005 and hwnd or handle,
but i cant get the textbox.hwnd og handle to work. I always get error
that
hwnd or handle is not a member of system.web.ui.webcontrols.

I want a code that can read how many lines that are in use in a textbox
that
are multiline and wrap enabled.

/Per W.

Option Strict On

Public Class Form1

Private Const EM_GETLINECOUNT As Integer = &HBA
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"_
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,_
ByVal lParam As Integer) As Integer

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Ret As Integer
Ret = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT, 0, 0)
TextBox1.Height = (Ret + 1) * TextBox1.Font.Height
End Sub
End Class
Thanx, buit i still get the Error 1 'Handle' is not a member of
'System.Web.UI.WebControls.TextBox'. D:\Dokumenter\Visual Studio
2005\WebSites\WebSite4\Default.aspx.vb 11 27 D:\...\WebSite4\

I have option strict on

/Per W.
Nov 19 '06 #3
On Sun, 19 Nov 2006 17:23:50 +0100, Per W. wrote:
"Gadget" <ga****@sobell.netskrev i melding
news:o6*****************************@40tude.net...
>On Sun, 19 Nov 2006 11:28:24 +0100, Per W. wrote:
>>Hi, can someone help me with this? I use VB.NET and are trying to the
EM_GETLINECOUNT to count lines in a textbox. But all examples that i have
found has to problemes. as any cant be used in VS2005 and hwnd or handle,
but i cant get the textbox.hwnd og handle to work. I always get error
that
hwnd or handle is not a member of system.web.ui.webcontrols.

I want a code that can read how many lines that are in use in a textbox
that
are multiline and wrap enabled.

/Per W.

Option Strict On

Public Class Form1

Private Const EM_GETLINECOUNT As Integer = &HBA
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"_
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,_
ByVal lParam As Integer) As Integer

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Ret As Integer
Ret = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT, 0, 0)
TextBox1.Height = (Ret + 1) * TextBox1.Font.Height
End Sub
End Class

Thanx, buit i still get the Error 1 'Handle' is not a member of
'System.Web.UI.WebControls.TextBox'. D:\Dokumenter\Visual Studio
2005\WebSites\WebSite4\Default.aspx.vb 11 27 D:\...\WebSite4\

I have option strict on

/Per W.
Web.UI??? In your whole last thread you didn't mention once that you were
running this on an ASP.NET page...

OK, well in that case forget this whole solution. The idea of auto-height
is dependent on things like browser text sise settings, so you might be
able to cludge something with System.Drawing.Graphics.MeasureString() as
Kevin mentioned, but it will possibly never be quite what you were
expecting.
You might also be able to create a server-side WinForm textbox and query
its height as above, then use that to generate you HTML height, but it's
all a bit of a bodge.

Cheers,
Gadget
Nov 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.