确定当前选定主题的光标大小
我想显示一个自定义鼠标光标,其大小与用户当前设置(在控制面板中)相匹配。
执行 Cursor.Current.Size 总是返回 32x32 (因为我猜它们总是技术上,尽管不是视觉上的),无论控制面板设置如何,较小或较大的光标外观都可以正确反映。
那么如何计算尺寸呢?
I want to show a custom mouse cursor, in a size that matches the current settings (in the control panel) of the user.
Doing Cursor.Current.Size always returns 32x32 (as I guess they always are technically, though not visually), no matter what the control panel settings, which are correctly reflected by smaller or bigger cursor appearances.
So how do I figure out the size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您必须获取光标的图标(可能使用某些 win32-API),然后使用 ICONINFO 找出掩码位图。之后,您可以检查图标的像素并计数,直到找到透明颜色,从而找出实际大小。
我在其他网站上看到了一些指向这个方向的答案,但我找不到完整的解决方案,只是到处都是片段。
这个 stackoverflow 问题对光标使用的位图掩码有一个很好的答案,从那里也许您可以按照自己的方式找到解决方案。
C# - 捕获鼠标光标图像
这个问题很旧,我有从2003年开始在其他网站上看到这个问题,所以如果你成功了,那么请将答案放在这里,很多人会很高兴看到这个问题的解决方案。
For what I have found out, you have to get the Icon for the cursor (probably with some win32-API) and then using ICONINFO to find out the mask bitmap. After that you can check the pixels of the icon and count until you find the transparent color and that way find out the real size.
I have seen a couple of answers on other sites that point to this direction, but I cant find a complet solution, just fragments here and there..
This stackoverflow question have a good answer about the bitmap masks used by the cursor and from there maybe you can work your way to the solution.
C# - Capturing the Mouse cursor image
This question is old, I have seen this question on other sites from year 2003, so if you have success, then please put the answer here, many would be glad to se the solution to this question.