Overriding MouseWheel
-
I'm trying to make a combo box where the mouse wheel does not work and/or bubbles the event up to the parent. Creating a new ComboBox class where OnMouseWheel is overridden does not work, nor does adding an event handler for the MouseWheel event. In both cases I get the event, but the combo box has already scrolled, defeating the purpose. Even when I put in a breakpoint I can see the new item in the combo box before my breakpoint is hit. Basically, in this app changing a combo box means reading in a whole set of new data, so I want to force the MouseWheel to be only for the scrollable area of the display. John Woodard
-
I'm trying to make a combo box where the mouse wheel does not work and/or bubbles the event up to the parent. Creating a new ComboBox class where OnMouseWheel is overridden does not work, nor does adding an event handler for the MouseWheel event. In both cases I get the event, but the combo box has already scrolled, defeating the purpose. Even when I put in a breakpoint I can see the new item in the combo box before my breakpoint is hit. Basically, in this app changing a combo box means reading in a whole set of new data, so I want to force the MouseWheel to be only for the scrollable area of the display. John Woodard
MouseWheel events are often a pain, as they are not part of the original Win32 API, and diverted to extra DLLs like those in IntelliPoint or Logitech mouse software. Standard window behaviour is to bubble the event to a parent window, and wheel scrolls are automatically handled. From your description, it sounds like wheel events are processed before OnMouseWheel() is called to signal the event, so presumably it just acts as a post-event notification. I have struggled with this before in both MFC and .Net. You might want to intercept WM_MOUSEWHEEL earlier on, by overriding PreProcessMessage(). Controls intercept all, and pre-handle several messages, at that stage, before passing the messages (and some never propogate further) to the defined event handlers. By not passing WM_MOUSEWHEEL to base.PreProcessMessage(), you should be able to keep the parent from handling it. Cheers