自定义鼠标光标的阴影 (2)

发布于 2024-10-31 13:19:41 字数 707 浏览 1 评论 0原文

在阅读了自定义鼠标光标的阴影问题的答案后,我做了一些测试。

从我的 Delphi 应用程序中,我加载了 32 位和 24 位版本的光标。从来没有影子。我对标准 Windows 箭头指针做了同样的事情。也没有影子。

我还尝试了相反的方法,并将自定义光标分配给 Windows 鼠标设置中的“正常选择”指针。 24位和32位指针都被赋予了阴影。

因此,光标中的 Alpha 通道似乎不会影响阴影行为。但我在我的申请中做错了什么?

第一步是通过 .rc 文件将光标添加到应用程序的资源中

CUR_EDGE_R Cursor DISCARDABLE "edge_r.cur"

,并在其加载的应用程序中:

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

那么,让 Windows 添加阴影到自定义光标的方法是什么?

注意:我在互联网上看到帖子建议创建两种版本的鼠标光标,一种有阴影,一种没有阴影,并根据用户的设置加载适当的光标。这不是我正在寻找的解决方案。

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

From my Delphi application I loaded both 32bit and 24bit versions of my cursor. Never a shadow. I did the same with the standard Windows arrow pointer. No shadow either.

Also I tried the opposite and assigned my custom cursors to the "Normal select" pointer in the Windows mouse settings. Both the 24bit and 32bit pointer were given a shadow.

So, it appears having an alpha channel in a cursor doesn't influence the shadow behaviour. But what am I doing wrong in my application?

First step is adding the cursor to the application's resources via an .rc file with

CUR_EDGE_R Cursor DISCARDABLE "edge_r.cur"

And in the application it is loaded with:

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

So, what is the way to have Windows add a shadow to a custom cursor?

Note: I have seen posts on the internet suggesting to create two version of the mouse cursor, one with and one without shadow, and load the appropriate cursor, depending on the user's settings. This is not the solution I'm looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若相惜即相离 2024-11-07 13:19:41

为了在自定义光标下放置阴影,您只需使用 Alpha 通道(可实现半透明)设计光标并在适当的位置绘制阴影即可。您甚至可以使用 Photoshop/GIMP(或任何其他有能力的图形编辑器)来生成具有“阴影”效果的光标,将其另存为 PNG,然后使用图标编辑器(例如 Microangelo)将 PNG 转换为光标。

据我了解,Windows Vista/7 附带的光标都不是设计为“平面”的,而是使用某些系统效果来生成阴影。

In order to place a shadow under your custom cursor, you simply design the cursor with an Alpha channel (which enables semi transparency) and draw your shadow in place. You can even use Photoshop/GIMP (or any other capable graphics editor) to produce your cursor with a "Drop Shadow" effect, save it as a PNG, then use an Icon Editor (such as Microangello) to convert the PNG to a cursor.

As I understand it, none of the cursors shipped with Windows Vista/7 are designed as "flat", using some system effect to generate their shadows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文