473,396 Members | 2,059 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,396 software developers and data experts.

Textbox innards

Where are the parameters/properties that control the
internal scroll bars of a text box (something like the
AutoScrollPosition X and Y values of a panel)?

Can you get and set these values with program code or
using an external control on the form?

Grateful for any help, but sincerely hope the answer is
not too complicated.
Nov 20 '05 #1
4 2082
* "simonc" <an*******@discussions.microsoft.com> scripsit:
Where are the parameters/properties that control the
internal scroll bars of a text box (something like the
AutoScrollPosition X and Y values of a panel)?

Can you get and set these values with program code or
using an external control on the form?


You can use pinvoke on 'SendMessage' + 'EM_SETSCROLLPOS'. Notice that
this will only work with the _RichTextBox_, not the simple textbox.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2
Thanks for this information. Unfortunately I have never
used any of these commands and am not really sure how to.
Please could you give an example.

Many thanks

Simon C
-----Original Message-----
* "simonc" <an*******@discussions.microsoft.com> scripsit:
Where are the parameters/properties that control the
internal scroll bars of a text box (something like the
AutoScrollPosition X and Y values of a panel)?

Can you get and set these values with program code or
using an external control on the form?
You can use pinvoke on 'SendMessage'

+ 'EM_SETSCROLLPOS'. Notice thatthis will only work with the _RichTextBox_, not the simple textbox.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
.

Nov 20 '05 #3
* "simonc" <an*******@discussions.microsoft.com> scripsit:
Thanks for this information. Unfortunately I have never
used any of these commands and am not really sure how to.
Please could you give an example.


Untested:

Use a RichTextBox control instead of the simple textbox. Untested (have a
look at the MSDN libarary for usage of 'EM_GETSCROLLPOS' and
'EM_SETSCROLLPOS'):

\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByRef lParam As POINTAPI _
) As Int32

Private Const WM_USER As Int32 = &H400
Private Const EM_GETSCROLLPOS As Int32 = (WM_USER + 221)
Private Const EM_SETSCROLLPOS As Int32 = (WM_USER + 222)

Private Structure POINTAPI
Public x As Int32
Public y As Int32
End Structure
///

Usage:

\\\
Dim pt As POINTAPI
pt.x = ...
pt.y = ...
SendMessage(Me.RichTextBox1.Handle, EM_SETSCROLLPOS, 0, pt)
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #4
Thank you very much. This code works fine.

The one thing I can't work out is how to send the message
whenever either scrollbar is moved. Because the scroll
bars are internal to the rich text box there doesn't seem
to be an accesible Scroll event that can trigger the
message. Is there a way of doing this?

Many thanks

-----Original Message-----
* "simonc" <an*******@discussions.microsoft.com> scripsit:
Thanks for this information. Unfortunately I have never
used any of these commands and am not really sure how to. Please could you give an example.
Untested:

Use a RichTextBox control instead of the simple textbox.

Untested (have alook at the MSDN libarary for usage of 'EM_GETSCROLLPOS' and'EM_SETSCROLLPOS'):

\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _ ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByRef lParam As POINTAPI _
) As Int32

Private Const WM_USER As Int32 = &H400
Private Const EM_GETSCROLLPOS As Int32 = (WM_USER + 221)
Private Const EM_SETSCROLLPOS As Int32 = (WM_USER + 222)

Private Structure POINTAPI
Public x As Int32
Public y As Int32
End Structure
///

Usage:

\\\
Dim pt As POINTAPI
pt.x = ...
pt.y = ...
SendMessage(Me.RichTextBox1.Handle, EM_SETSCROLLPOS, 0, pt)///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
.

Nov 20 '05 #5

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

Similar topics

0
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
0
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
1
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.