Shadow for custom mouse cursor (2)

After reading the answer to the Shadow question for a custom mouse pointer , I did some testing.

From my Delphi application, I downloaded the 32-bit and 24-bit versions of my cursor. Never a shadow. I did the same with the standard Windows arrow pointer. Also there is no shadow.

I also tried the opposite and assigned my custom cursors to the "Normal selection" pointer in the Windows mouse settings. Both the 24-bit and 32-bit pointer got a shadow.

So, it looks like the alpha channel in the cursor does not affect the behavior of the shadow. But what am I doing wrong in my application?

The first step is to add the cursor to the application resources via the .rc file with

CUR_EDGE_R Cursor DISCARDABLE "edge_r.cur" 

And in the application it loads:

 const crEdgeR = TCursor(135); . . Screen.Cursors[crEdgeR] := LoadCursor(HInstance, 'CUR_EDGE_R'); 

So how can Windows add a shadow to a user cursor?

Note. I saw messages on the Internet suggesting to create two versions of the mouse cursor, one with one and no shadow, and load the corresponding cursor depending on user settings. This is not the solution I'm looking for.

+4
source share
1 answer

To place a shadow under your custom cursor, you simply create a cursor with an alpha channel (which provides translucency) and draw a shadow in place. You can even use Photoshop / GIMP (or any other capable image editor) to create your cursor with the Drop Shadow effect, save it as a PNG, and then use the icon editor (like Microangello) to convert the PNG to cursor.

As I understand it, none of the cursors shipped with Windows Vista / 7 was designed to be β€œflat,” using some system effect to generate their shadows.

0
source

Source: https://habr.com/ru/post/1347210/


All Articles