473,763 Members | 7,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox Scroll events

I want to react to scrolls in a RichTextBox (I want to let the user know
when he has changed to a new printable page.) I have handled the VScroll()
event, but that only responds to scrollbar clicks. If the user slides the
"thumb", I seem to get no indication. Anyone know how to get notified of the
thumb slide from a RichTextBox? I can derive from RichTextBox and trap
messages if need be, but I have not been able to figure out what to respond
to (and I'm still hoping for a better way that I don't have to create a
derived class?)

-Rachel
Nov 17 '05 #1
3 9411
Rachel

Try to use the WM_VSCROLL event.

//example:
public class HRichTextBox : System.Windows. Forms.RichTextB ox
{
private const int WM_VSCROLL = 277;

public event System.EventHan dler OnVerticalScrol l;

public HRichTextBox()
{
}

protected override void WndProc(ref System.Windows. Forms.Message m)
{
if(m.Msg == WM_VSCROLL && OnVerticalScrol l != null)
OnVerticalScrol l(this, new System.EventArg s()); // your new vscroll
event handler

base.WndProc (ref m);
}
}

Yong Hyeok Seo
hy***@inbrein.c om
MCAD, MVP[C#]

"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:eL******** *****@TK2MSFTNG P15.phx.gbl...
I want to react to scrolls in a RichTextBox (I want to let the user know
when he has changed to a new printable page.) I have handled the VScroll()
event, but that only responds to scrollbar clicks. If the user slides the
"thumb", I seem to get no indication. Anyone know how to get notified of
the
thumb slide from a RichTextBox? I can derive from RichTextBox and trap
messages if need be, but I have not been able to figure out what to
respond
to (and I'm still hoping for a better way that I don't have to create a
derived class?)

-Rachel

Nov 17 '05 #2
Thanks. It looks like this is part of the solution. WM_VSCROLL notification
is sent more often than I want to handle this event (eg twice for every
scroll button click), and it isn't sent at some times I want to be notified
(like up/down arrows causing a scroll.) To catch it only when I want it,
I'll need to look at the wParam. I can choose either SB_THUMBPOSITIO N or
SB_THUMBTRACK (depending on whether I want to update only when the mouse is
released or during scrolling), but I will need to avoid looking at the
high-order word if I want to test for equality (which I do, since these are
not defined as flags -- they are 4 and 5 repectively.)

I believe it will work to use the existing VScroll event, and do something
like this:

protected override void WndProc(ref System.Windows. Forms.Message m)
{
if ( m.Msg == WM_VSCROLL &&
(short) m.WParam == SB_THUMBPOSITIO N )
OnVScroll( this, EventArgs.Empty );
base.WndProc ( ref m );
}

-Rachel

"hyuki" <hy***@inbrein. com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
Rachel

Try to use the WM_VSCROLL event.

//example:
public class HRichTextBox : System.Windows. Forms.RichTextB ox
{
private const int WM_VSCROLL = 277;

public event System.EventHan dler OnVerticalScrol l;

public HRichTextBox()
{
}

protected override void WndProc(ref System.Windows. Forms.Message m)
{
if(m.Msg == WM_VSCROLL && OnVerticalScrol l != null)
OnVerticalScrol l(this, new System.EventArg s()); // your new vscroll event handler

base.WndProc (ref m);
}
}

Yong Hyeok Seo
hy***@inbrein.c om
MCAD, MVP[C#]

"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:eL******** *****@TK2MSFTNG P15.phx.gbl...
I want to react to scrolls in a RichTextBox (I want to let the user know
when he has changed to a new printable page.) I have handled the VScroll() event, but that only responds to scrollbar clicks. If the user slides the "thumb", I seem to get no indication. Anyone know how to get notified of
the
thumb slide from a RichTextBox? I can derive from RichTextBox and trap
messages if need be, but I have not been able to figure out what to
respond
to (and I'm still hoping for a better way that I don't have to create a
derived class?)

-Rachel


Nov 17 '05 #3
Thanks. It looks like this is part of the solution. WM_VSCROLL notification
is sent more often than I want to handle this event (eg twice for every
scroll button click), and it isn't sent at some times I want to be notified
(like up/down arrows causing a scroll.) To catch it only when I want it,
I'll need to look at the wParam. I can choose either SB_THUMBPOSITIO N or
SB_THUMBTRACK (depending on whether I want to update only when the mouse is
released or during scrolling), but I will need to avoid looking at the
high-order word if I want to test for equality (which I do, since these are
not defined as flags -- they are 4 and 5 repectively.)

I believe it will work to use the existing VScroll event, and do something
like this:

protected override void WndProc(ref System.Windows. Forms.Message m)
{
if ( m.Msg == WM_VSCROLL &&
(short) m.WParam == SB_THUMBPOSITIO N )
OnVScroll( this, EventArgs.Empty );
base.WndProc ( ref m );
}

-Rachel

"hyuki" <hy***@inbrein. com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
Rachel

Try to use the WM_VSCROLL event.

//example:
public class HRichTextBox : System.Windows. Forms.RichTextB ox
{
private const int WM_VSCROLL = 277;

public event System.EventHan dler OnVerticalScrol l;

public HRichTextBox()
{
}

protected override void WndProc(ref System.Windows. Forms.Message m)
{
if(m.Msg == WM_VSCROLL && OnVerticalScrol l != null)
OnVerticalScrol l(this, new System.EventArg s()); // your new vscroll event handler

base.WndProc (ref m);
}
}

Yong Hyeok Seo
hy***@inbrein.c om
MCAD, MVP[C#]

"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:eL******** *****@TK2MSFTNG P15.phx.gbl...
I want to react to scrolls in a RichTextBox (I want to let the user know
when he has changed to a new printable page.) I have handled the VScroll() event, but that only responds to scrollbar clicks. If the user slides the "thumb", I seem to get no indication. Anyone know how to get notified of
the
thumb slide from a RichTextBox? I can derive from RichTextBox and trap
messages if need be, but I have not been able to figure out what to
respond
to (and I'm still hoping for a better way that I don't have to create a
derived class?)

-Rachel


Nov 17 '05 #4

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

Similar topics

2
2724
by: JRB | last post by:
I have a thread adding lines of text to a richtextbox on my windows form about every 1 second. I want the last line of text to always be visible, which it is until the box gets filled up. The last line is always visible if the cursor is on the richtextbox, But if I'm working on another richtextbox on the form, the one that is continually getting text doesn't scroll down automatically. Is there any way to get it to automatically show the...
6
29231
by: Rachel Suddeth | last post by:
I have the index of a line in the Lines array of a RichTextBox. I would like to have it scroll so that line displays at the top. Is there no way to do this? The only way I can see to make it scroll is with ScrollToCaret(). But I don't know how to set the "caret" to a particular line. Any suggestions? -Rachel
4
4423
by: One Handed Man | last post by:
Ive been working on this since yesterday and its bugging me. Although the event is firing, The box does not scroll. Can anyone see what Im doing wrong. I suspect it is stupidly simple. TIA
2
17374
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to the control or the scrolltocaret method I decided that it would be worth posting to anyone who might have similar concerns. For the record this works well in an environment where you cannot have focus going to the richtextbox....such as a chat...
7
2059
by: Richard | last post by:
When you give focus to a RichTextBox, then it goes to the textCursor, but i don't want to give the richtextbox focus, cause there is being written a lot in it, and I have to do something else at the same time, then if I don't give it focus, and I add some text to it, then it don't automaticly scrolls down to the textcursor, is there a way to make the RichTextBox scroll down to the textcursor, without giving it focus?? Richard
1
5580
by: Daniel Friend | last post by:
How do I scroll to the bottom of RichTextBox Currently tried RichTextBox1.SelectionStart=len(RichTextBox1.text) RichTextBox1.ScrollToCaret This does not work. What is the best what to accomplish this
0
1081
by: tcloud | last post by:
I have a RichTextBox that: - 1st would intermittently show the scroll bars but they wouldn't work - 2nd now doesn't allow any interaction even though it looks normal The application processes pure text files up to 20 MB. The data is processed and summed into StringBuilder and then placed into the RichTextBox using: -- rtxt1.Text = strBuilder.ToString() The RichTextBox is initially set up on the form as:
1
2900
by: dotnetnoob | last post by:
i have a Dialog form with richtextbox that basically display a legal agreement and when the user drag the scroll thumb down to the end of scrolling which suppose to mean the user have read it then the checkbox is enabled for the user to tick off (I agree) and the next button is enabled for user to click next. the richtextbox vscroll event only fire when user click on the scrollthumb and that's it. how do i implement it when user drag the...
2
9779
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, I have a somewhat long calculation report printed out in a RichTextBox. To find or monitor a particular value, users scroll down to the location of the data in the RichTextBox. However, when the user changes the input data, a recalculation is made and a new report is generated. This resets the RichTextBox vertical scroll bar to the top. I would like to be able to read the position the scroll bar is moved to before recalculation....
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9997
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 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...
1
9937
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,...
0
9822
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 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...
1
7366
isladogs
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...
0
6642
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();...
0
5270
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...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.