开发者

How do I make a custom system wide mouse cursor animation?

开发者 https://www.devze.com 2022-12-21 11:17 出处:网络
I write software for the disabled.开发者_如何学运维 One of the problems is difficulty tracking the mouse pointer. I want to have the mouse cursor glow (or similar effect. Maybe water like ripples arou

I write software for the disabled.开发者_如何学运维 One of the problems is difficulty tracking the mouse pointer. I want to have the mouse cursor glow (or similar effect. Maybe water like ripples around it) when the user needs to locate it. How is this done? I know it's possible because it's used in a variety of software.


You can create custom animated cursors "on the fly" by using CreateIconFromResource and painstakingly creating the cursor data structures yourself. I recently added some tests to the Wine project for creating cursors in this way, you can take a look at the structure of the cursor data by looking at this example for a three-frame cursor: http://source.winehq.org/source/dlls/user32/tests/cursoricon.c?v=wine-1.3.16#L222


Have a look at Realworld Cursor Editor found here.

Edit: As the OP pointed out, the OP was looking for a way of creating an animated cursor programmatically, using Win32API. AFAIK it cannot be done or is long-winded way of doing it, the 'LoadCursor' function can load the cursor from an embedded resource or a file on disk with an extension .ani, hence my answer in support for the usage of Realworld Cursor Editor which can create an .ani file containing animated cursors, the other way of doing it is to use the 'Control Panel' > 'Mouse', click on 'Pointers' tab-page on the dialog itself to set it as system-wide settings. Here is a sample of how an animated cursor gets loaded here.

Hope this helps, Best regards, Tom.


An alternative approach is to leave the cursor as-is, and instead add some effects around it, using, for example, a temporary topmost layered window that you draw some animation on. (eg. alpha-blended circles to get a glow effect around the cursor position.)

This has the advantage of leaving the cursor unchanged, so if it's conveying information (eg. hourglass or size handle), you're not interfering with that.


If all you need to do is make ripples appear around the cursor, there is a setting you can change in the mouse section of control panel such that ripples appear around the cursor when the CTRL key is pressed.

0

精彩评论

暂无评论...
验证码 换一张
取 消