“Hiding” System Cursor

后端 未结 2 415
陌清茗
陌清茗 2020-12-18 12:16

BACKGROUND:

  • I\'m trying to create a \"mouse hiding\" application that hides the user\'s mouse from the screen after a set amount of time.
  • I\'ve trie
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 12:36

    I found a good workaround for hiding system cursor temporarily that doesn't involve screwing around with setsystemcursor().

    SetSystemCursor() is dangerous, because if the app crashes or otherwise throws a bug, the cursor will be changed permanently until the next reboot.

    Instead, I implemented a transparent window over the whole desktop, and that window hides the cursor when needed. The method to use is ShowCursor from Win32.

    The transparent window can be something like this: http://www.codeproject.com/Articles/12597/OSD-window-with-animation-effect-in-C

    [DllImport("user32.dll")]
    static extern int ShowCursor(bool bShow);
    
    ShowCursor(false);
    

提交回复
热议问题