MouseWheel & ScrollBars

D

Daisy

I've got a control with a scrollbar docked to the right-hand side. The
scrollbar works fine, I've got an event:

bottomControlVScroll.Scroll += new
ScrollEventHandler(HandleBottomThingScroll);

Which calls this.Invalidate() on my control, and all is good. However, the
MouseWheel does naff all. I understand this is probably because my mouse is
over my control, and not the scrollbar. How can I set the MouseWheel event
on my control to pass to the ScrollBar, where the .Value is updated, and my
control invalidated & repainted?
 
H

Hector Yunier

-----Original Message-----
I've got a control with a scrollbar docked to the right- hand side. The
scrollbar works fine, I've got an event:

bottomControlVScroll.Scroll += new
ScrollEventHandler(HandleBottomThingScroll);

Which calls this.Invalidate() on my control, and all is good. However, the
MouseWheel does naff all. I understand this is probably because my mouse is
over my control, and not the scrollbar. How can I set the MouseWheel event
on my control to pass to the ScrollBar, where the .Value is updated, and my
control invalidated & repainted?

Make the MouseWheel event of your control, go to
your HandleBottomThingScroll() method.

I hope this help.....
 
D

Daisy

Daisy said:
I've got a control with a scrollbar docked to the right-hand side. The
scrollbar works fine, I've got an event:
<snip>

Scrap that, the wheel works now, I altered .Value depending on e.Delta :blush:)

Anyways, the only problem now, is that it only works while my mouse is over
the scrollbar, and not anywhere in my control. I even added:

this.MouseWheel += new MouseEventHandler(HandleBottomThingWheel);

In the Constructor, and it still doesn't work for the control :(
Any ideas?
 
D

Daisy

Hector Yunier said:
Make the MouseWheel event of your control, go to
your HandleBottomThingScroll() method.

I hope this help.....

It does now:

bottomControlVScroll.Scroll += new
ScrollEventHandler(HandleBottomThingScroll);
bottomControlVScroll.MouseWheel += new
MouseEventHandler(HandleBottomThingWheel);
this.MouseWheel += new MouseEventHandler(HandleBottomThingWheel);

But the wheel still only works when over the scrollbar :-((
 
T

Trevor

I am not sure if you have already tried this but, is there a way to hook
into MouseWheel notifications for the window (parent of the scrollbar)
instead of the scrollbar itself? Then you could simply forward the message
on to the scrollbar control.
 
D

Daisy

Trevor said:
I am not sure if you have already tried this but, is there a way to hook
into MouseWheel notifications for the window (parent of the scrollbar)
instead of the scrollbar itself? Then you could simply forward the message
on to the scrollbar control.

How do I "forward" them on? I can't call MouseWheel directly?
 
H

Harkos

Try creating a composite control (if you're not already using) and
overriding the OnMouseWheel event. Do everything you need there. Works for
me.

[]'s,
Harkos
 
D

Daisy

Harkos said:
Try creating a composite control (if you're not already using) and
overriding the OnMouseWheel event. Do everything you need there. Works for
me.

It's ok, it already works. I've got a cráppy Vaio mouse on this laptop,
along with a USB keyboard with it's own cráppy drivers. Must be them, works
on every other pc :blush:)
 

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