MouseFilter component

Provides methods to change the mouse behaviour in applications.

This component provides the following functions:

Hiding the mouse cursor after a while of inactivity

In fullscreen applications it may be useful to hide the mouse cursor when not using it. Therefore all Windows messages sent to the running application are monitored and the cursor is hidden when the mouse wasn’t moved for a while. Moving the mouse immediately shows the cursor again, until the next inactivity timeout. This function can be activated with the AutoHideCursor property. Additionally, the events MouseHidden and MouseShown notify when the cursor has been hidden resp. shown.

Dispatching of mouse wheel input to the control below the mouse cursor

Normally, mouse wheel input always goes to the control which holds the keyboard input focus. But since that wheel is mounted to the mouse and not the keyboard, it should follow the mouse cursor’s position more than the keyboard focus. Due to the way how Windows sends the corresponding messages however, you cannot scroll in an inactive window even with the cursor over it. This function can be activated with the DispatchMouseWheel property.

Compatibility: .NET Version 2.0 or newer


As this component uses several files that I usually employ in my own applications, I’m offering a simple example application for download only. It contains the full required source code of the component and also demonstrates its usage. The component’s files are located in the subdirectory “Unclassified”.

mousefilter.7z13.6 KiBExample project (Visual Studio 2005/2010, C# projekt) including the source code of the MouseFilter component and a small test application.

In general, you only need to add an instance of the MouseFilter component to one of your application’s forms in order to use these functions. As the component registers itself as MessageFilter for the entire application, you should add it to the main window. While additional usage in other windows should be unproblematic, it should be avoided.

This component was only tested in Windows Forms applications by now. I don’t know how well it works in WPF applications. At least the mouse wheel dispatching seems to be unnecessary with WPF because that behaviour is already there.


Unterstützung für ComboBox-Controls und Scroll-Panels verbessert.

Licence and terms of use

This software is released under the terms of the simplified BSD licence. You can find the detailed terms and conditions in the download.

Statistic data

  • Created on 2007-09-16, updated on 2011-08-29.
  • First used in ARLog: Amateur Radio Logbook.
  • Ca. 120 lines of code, estimated development costs: 120 - 480 €