Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / General Programming / Disabling Mouse Message/Movement/Etc. Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Kevin Bass

January 28, 2005, 04:01 PM

I would like to know if there is any way to disable/re-enable the mouse through Win32 function calls. I bascially want to call a function that will cause the mouse to stop functioning, or at least stop sending messages or something to that effect.

I have tried different methods such as hooking into the windows process, sub-classing, ect. but nothing seems to work 100%. I can add a mouse hook and receive the mouse messages however, this doesnt not stop the mouse messages from continuing down the list of other windows and controls.

Is there a method that might work that I am overlooking, or is it not possible.

Any help would be appreciated.

Just in case...
I am developing on XP Pro, using VC++ 6.0

Jean-Francois Marquis

January 28, 2005, 04:48 PM

Look at ShowCursor( ).
I'm pretty sure Windows stops sending mouse messages when the cursor is not visible. ShowCursor is process-dependant though, but that should be enough to stop messages to your window.


January 28, 2005, 09:03 PM

Use SetCapture() to capture the mouse. Then all mouse messages will go to your app only, no mattere where the mouse is on the screen. Since it is your own app it is easy to ignore the messages.


January 30, 2005, 01:14 AM

I know ShowCursor() wont solve my problem, not sure about SetCapture(). What I am wanting is to disable the mouse entirely or trap the messages to the mouse, even if my app is not the active one.

For example, if a user clicks on the desktop, start button, or another app then my app would lose focus. In other words if my app is running, and I "turn off the mouse" mouse clicks do nothing.

Any additional information would be great.



January 30, 2005, 06:45 AM

Im not sure but i think this cant be done in application code due to structure of XP systems. In win98 there was a function named SystemParametersInfo() with SPI_SCREENSAVERRUNNING flag that disabled input to other aplications, but this isnt working any more for NT based systems like XP. I think that for this purpose services or drivers are need to be used, but i dont know how to do it.

Julien Houllier

February 04, 2005, 03:56 AM

SetCapture() is the function you are looking for...
Don't forget to ReleaseCapture() when shutting down your app... ;)

This thread contains 7 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.