Thanks for the responses in a former thread about getting the count of lines
in a multiline textbox with wordwrap.
After some tinkering, I found the solution (based on a VB6 solution, had to
modify a bit for VB.NET):
<DllImport("use r32.dll")> Private Shared Function SendMessage(ByV al hWnd As
IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32)
As Int32
End Function
Dim EM_GETLINECOUNT As Long = &HBA&
Dim lineCount As Int32 = SendMessage(txt Box.Handle, EM_GETLINECOUNT , 0, 0&)
Works like a charm. 3 3907
Hi HDB,
Did not see such a compact solution for this problem before.
And although that it is an API, which I think you should avoid in dotnet, I
put it in my snippets because it is such a special purpose.
(Most that I saw had to do with measure line height and box height, which I
did found terrible and a lot of work when the texbox would be resizable)
However this compact code I save.
Thanks
Cor
"HDB" <no***********@ donotspam.kpn.c om> wrote in message
news:c7******** **@hdxl22.telec om.ptt.nl... Thanks for the responses in a former thread about getting the count of
lines in a multiline textbox with wordwrap.
After some tinkering, I found the solution (based on a VB6 solution, had
to modify a bit for VB.NET):
<DllImport("use r32.dll")> Private Shared Function SendMessage(ByV al hWnd
As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32 End Function
Dim EM_GETLINECOUNT As Long = &HBA&
That should be changed to:
[Public|Private] Const EM_GETLINECOUNT As Integer = &HBA
Long is 64 bits in VB.NET. In fact, the following call to SendMessage
should give you an error if you have Option Strict On (It is on right?).
Other then that - this is a good way to do what you want.
Dim lineCount As Int32 = SendMessage(txt Box.Handle, EM_GETLINECOUNT , 0,
0&) Works like a charm.
Tom Shelton [MVP]
* "Cor Ligthert" <no**********@p lanet.nl> scripsit: And although that it is an API, which I think you should avoid in dotnet, I put it in my snippets because it is such a special purpose.
Why avoid p/invoke?!
*shocked*
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew Dalke |
last post by:
Is there an author index for the new version of the
Python cookbook? As a contributor I got my comp version
delivered today and my ego wanted some gratification.
I couldn't find my entries.
Andrew
dalke@dalkescientific.com
|
by: Vasilis Serghi |
last post by:
Presently I define the number of lines to be expected in a file when
defining the array size and the initialisation of this array. This works
fine for now, but i'm sure that in the future this could change. So rather
than explicitly define the number expected, the file is read and the number
defined that way.
So I have a csv file that I can read in, how can I work out the number of
lines in the file? Is there a function that can do this,...
|
by: Anders K. Jacobsen [DK] |
last post by:
Hi
We have a rather large asp.net project with serveral utility projects
(written in C#). Is there at tool out there which can give an estimate of
the total amount of code lines all projects results in?
thanks in regads
Anders
|
by: Neo Geshel |
last post by:
After pouring over about a dozen sites that clearly dealt with ClientID
all by itself, I came to the realization that about 2/3+ of them were
doing it wrong. It is indeed impossible to grab the Client ID of a form
field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At
least, not without extra work.
How did I do this? I created a new DataGrid from scratch, with a form
above it and a form inside of it. This was a page...
|
by: HDB |
last post by:
Ok. I have a windows form with a textbox for displaying certain messages.
Multiline=true and wordwrap=true. I want to know the amount of the lines
currently showing. That should not be any rocket-science, eh?
Textbox.lines.length() only returns the amount of lines ending with a 'hard'
CrLF, not the lines with a 'soft' CrLf done by the wordwrapping option. Why,
I don't know. I don't want to know how much lines are ending with 'hard'
CrLf....
| |
by: geolev |
last post by:
I'm trying to understand the effects of the Daylight Saving Time rule
changes for 2007 in the US. Can anyone tell me how Javascript knows
when to apply Daylight Saving Time in the following script?
d1 = new Date(2006, 03, 01, 23, 00);
d2 = new Date(2006, 03, 02, 04, 00);
// Reports "This is ok: The answere should be 4. It is 4".
alert("This is ok: The answer should be 4. It is " + (((d2.valueOf()
- d1.valueOf())/1000)/60)/60);
|
by: =?Utf-8?B?SGFucyAtIERpYUdyYXBoSVQgLQ==?= |
last post by:
Hi!
sorry for a dumb question. I have a textbox where multiline=true and I want
to set the scrolbar from none to vertical when the textbox have more then
f.ex. 5 lines,
or reverse.
How can I count the amount of lines in a textbox?
Best regards
|
by: peraklo |
last post by:
Hello,
there is another problem i am facing. i have a text file which is
about 15000 lines big. i have to cut the last 27 lines from that file
and create a new text file that contans those 27 lines. and after that
save both of those files... since that is a big block of text (15000
lines) i thint that it is a big job to look for a keyword... so my
question is this exactly:
how do i do this:
|
by: Anthony P. |
last post by:
Hello Everyone,
I'm building an application and need to keep track of the amount of
text in a textbox to make sure the user knows how many characters they
have left to type. I've set the textbox's max length to 120 and that
works fine. Now, I have a label that displays characters remaining in
the textbox. For each keypress I am decrementing the counter (and
label value) by one and when the user presses the backspace key, I am...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |