Discovering the Globally Active Mouse Cursor Icon in Windows

For a video streaming project, I had to retrieve the active icon type and the coordinates of the mouse cursor in a Windows environment. While discovering the coordinates of the mouse cursor wasn’t too awful, discovering which of the possible mouse icons was currently active was anything but a pleasurable experience.

To try and simplify the process of pulling mouse information out of the depths of the Windows API, I’ve created a (hopefully) simple C++ class that attempts to wrap up all the details you might care about. This class provides methods for retrieving the mouse coordinates and the particular icon currently being rendered by Windows. The icon is returned as a custom enumeration, and the coordinates are returned as a POINT.

IC41543

This method makes use of the Windows API call GetCursorInfo and the structure it populates named CURSORINFO. In addition, we also need to use the LoadCursor function to retrieve information about known cursor icons from Windows. The cursors the class is able to detect are the cursors defined in the LoadCursor documentation.

For more details about how this class works, please see the header file, the cpp file, and the Windows API calls linked earlier in this post. I hope this helps!