views:

24

answers:

1

I want to hover over a picturebox (or all pics and the main form) and use the mousewheel to scroll. However i have no luck. I wrote pictureBox1.MouseWheel and check the delta. I set a breakpoint for when it != 0. So far no matter what i did i couldnt get anything to happen. I tried mousemove as well and that didnt work. However breaking on the if statement works. I just can never get the wheel to work.

How do i make picturebox (or any control in the form) call a mousewheel event?

-edit- nevermind. I added the event to the object that has the event most of the time. It works pretty well. I am not sure why i didnt think of this before i wrote this question. I am still open to mouse over + wheel solutions.

+1  A: 

Windows doesn't send the mouse scroll message to the control that's hovered, it goes to the control with the focus. You already know how to fix the focus.

This behavior is getting unintuitive because of the way browsers and Office programs work. You'll find code to alter this in my answer in this thread. Beware that it works on any window in your app. You'll have to add filtering on the handle value if that's undesirable.

Hans Passant
Excellent answer. You really helped me with all my GUI needs.
acidzombie24