Overriding OnMouseWheel
-
I've extended the PictureBox control to create my own user control. Now I want to capture the
OnMouseWheel
. I've done this many times, and it's usually enough to override like thisprotected override void OnMouseWheel(MouseEventArgs e)
. Unfortunately the overidden method is never called when I turn my mousewheel. I've also tried tying the
MouseWheel
even to my own method. Weird enough, this isn't called either... Could this be related to the parent control the box is placed in? Any suggestions?Standards are great! Everybody should have one!
-
I've extended the PictureBox control to create my own user control. Now I want to capture the
OnMouseWheel
. I've done this many times, and it's usually enough to override like thisprotected override void OnMouseWheel(MouseEventArgs e)
. Unfortunately the overidden method is never called when I turn my mousewheel. I've also tried tying the
MouseWheel
even to my own method. Weird enough, this isn't called either... Could this be related to the parent control the box is placed in? Any suggestions?Standards are great! Everybody should have one!
You might try creating a user control that you know has the OnMouseWheel event enabled. Another option would be to inherit from the picturebox and override its WndProc with information related to the mouse wheel.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]
-
You might try creating a user control that you know has the OnMouseWheel event enabled. Another option would be to inherit from the picturebox and override its WndProc with information related to the mouse wheel.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]
The picture box should have this event enabled. I've tried the following and found it to be working: The form is placed within a
SplitContainer
control. Since I was guessing it might be the parent container that was the problem, I tried tying my method toSplitContainer.Panel1.MouseWheel
event first. When this wasn't working, I tied it toSplitContainer.MouseWheel
. This actually works. This seems very strange because I've always thought that events were passed from the toplevel container on to the back. The solution isn't very charming, since this means the control I made will have to be hooked differently to it's parent controls, depending on the type of parent it's placed In. Overriding its WndProc seems like a good idea, it's just that I have no idea of how to do this. If you can give me a pointer that would be very welcome, it's almost weekend for me and I don't feel like starting it with leaving an annoying problem like this unsolved ;)Standards are great! Everybody should have one!
-
I've extended the PictureBox control to create my own user control. Now I want to capture the
OnMouseWheel
. I've done this many times, and it's usually enough to override like thisprotected override void OnMouseWheel(MouseEventArgs e)
. Unfortunately the overidden method is never called when I turn my mousewheel. I've also tried tying the
MouseWheel
even to my own method. Weird enough, this isn't called either... Could this be related to the parent control the box is placed in? Any suggestions?Standards are great! Everybody should have one!
I know it's 4 years too late, but I ran across this post while looking for information on the Delta values in the
MouseEventArgs
passed toOnMouseWheel
. The reason controls likePictureBox
don't fire that event is because it doesn't have focus. An easy fix should be to overrideOnMouseEnter
and calling the control'sFocus()
method. You may also need to call your control'sSetStyle
method and give itControlStyles.Selectable
in it's contructor. It's probably way too late, but I hope that helps anyway. :)"Political correctness is a doctrine, fostered by a delusional, illogical minority, and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end" - Unknown
-
I know it's 4 years too late, but I ran across this post while looking for information on the Delta values in the
MouseEventArgs
passed toOnMouseWheel
. The reason controls likePictureBox
don't fire that event is because it doesn't have focus. An easy fix should be to overrideOnMouseEnter
and calling the control'sFocus()
method. You may also need to call your control'sSetStyle
method and give itControlStyles.Selectable
in it's contructor. It's probably way too late, but I hope that helps anyway. :)"Political correctness is a doctrine, fostered by a delusional, illogical minority, and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end" - Unknown
Was surprised to see a reply to a 4 year old question that I didn't remember I asked in my inbox :). Thanks for the answer. Perhaps the problem has been haunting my subconsciousness for 4 years and is finally at peace ;). More likely I found a way around it back then though. Still; others may find your answer very useful, thanks again.
Standards are great! Everybody should have one!