How to copy system cursors properly?

d3x0r 0 Reputation points
2023-06-22T03:54:34.2533333+00:00

I'm trying to Hide the mouse after a certain time from a console application. ShowCursor() does not work.

I find I can do SetSystemCursor with a blank cursor... but then when I restore the cursors they are not the same; especially if I use the cursor scaling option (HKEY_CURRENT_USER/control panel/cursors/CursorBaseSize), which if I use that to copy the cursor doubles the size of the cursor (approximately)

https://github.com/d3x0r/sack.vfs/blob/master/src/system_module.cc#L265-L333

is the fragment of code... it does a CopyCursor( LoadCursor(NULL, IDC_*)) and then sets the cursor to blank when it finds the cursor position hasn't moved; and restores the icons using SetSystemCursor( CopyCursor( hOldCursor[n]), oldCursors[n]) for all cursors.

I'm also using CopyImage instead of the default function #define CopyCursor(icon) (HCURSOR)CopyImage( icon,IMAGE_CURSOR,0, 0,0)

such that I am supposed to be able to copy animated cursors). Although, I find that if I search for that, that people have asked since 2000 how to use CopyImage to actually copy the cursor. If I use the default like above, then the cursor becomes highly pixelated.
If I use the basecursorsize from the registry in the size then it gets big and blurry.

#undef CopyCursor

#define CopyCursor(icon) (HCURSOR)CopyImage( icon,IMAGE_CURSOR,cursorSize, cursorSize,0)

Left is the original sharp cursor, the middle is copy with 0,0, the right is copy with cursor base size.
User's image

  1. how do I use DrawImage to copy an animated cursor (I haven't yet looked at (Figured out a way to force in order to look at) the wait cursor which is animated, and maybe it IS... but I suspect it's not copying.
  2. How do I copy the current cursor set in the correct size and sharpness to be able to restore?
  3. Why is this so hard to just hide the cursor? Looks like mostly iff the cursor is moved anyway it gets restored by application default behaviors. (Others have complained that they can get ShowCursor(FALSE) to work, but then it automatically comes back).
Windows development | Windows API - Win32
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.