Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Overriding MouseWheel

Overriding MouseWheel

Scheduled Pinned Locked Moved C#
debugging
2 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jpwkeeper
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J jpwkeeper

      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

      J Offline
      J Offline
      Jeff J
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups