You are here:

C++/How can I hide the system cursor


In Windows XP, I would like to hide the system cursor instead of just hiding the cursor within my application (not too hard to do) once the mouse is idle for a certain period of time. So if my app is running (and say the size of the app is small enough that you can see the desktop still) and if the cursor is hovering on the desktop, I want to not have the cursor be visible.

However, no matter what I've tried, I can't seem to hide the system cursor. I've gotten the window handle for which cursor is sitting under ( and then change the cursor using SetCursor(NULL) but no avail.

The other thing I've tried is using a hook (SetWindowsHookEx) to trap WM_MOUSEMOVE and then set up a timer to see how long it's been idle. At a specified time, I call SetCursor(NULL) but it also doesn't work. Seems that when you call SetCursor from the timerProc, you're no longer at the global level to change the system cursor.

Do you have any other suggestions that I could try?


Justin, Thank you for your question.

The call SetCursor(NULL) is ignored by the system on some versions of Windows. To set the cursor invisible, construct an actual invisible cursor using the CreateCursor function. See the MSDN Library documentation for details.

I have my doubts about your app. Making the cursor invisible system-wide does not seem to be a good idea unless all of your apps are guaranteed to be image displaying apps (in which case some argument can be made for hiding the cursor). Hiding the cursor means that the mouse must be moved before the user can see where it is.

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2017 All rights reserved.