如何判断鼠标指针图标是否已更改 [英] How to tell if mouse pointer icon changed

查看:113
本文介绍了如何判断鼠标指针图标是否已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Delphi 7中为Windows编写一个屏幕录制应用程序,希望知道鼠标指针在我的应用程序中何时发生了变化(例如从普通指针到调整大小的指针等).

I'm writing a screen recording app for Windows in Delphi 7 and wish to know when the mouse pointer changes in my app (like from a normal pointer to a resize pointer, etc).

当前我正在做的是每次鼠标移动(和在计时器上)将鼠标指针绘制到内存中的位图上,并将其与我最后绘制的位图进行逐像素比较.

Currently what I'm doing is painting the mouse pointer onto an in-memory bitmap everytime the mouse moves (and on a timer) and doing a pixel by pixel comparison of it with the last bitmap I painted.

尽管比较相当快(大约2-5毫秒),因为它发生的频率很高(每次鼠标移动),所以它加起来了.我认为必须有一种更快,更简单的方法!

Though the comparision is fairly quick (about 2-5ms) because it's happening so often (every mouse move) it adds up. I figure there has to be a faster and less complicated way!

推荐答案

您有游标的句柄,对吗?如果它与您之前具有相同的句柄值,那么我认为假设它看起来也一样是合理的.如果光标看起来不同,它将具有不同的句柄值.

You have a handle to the cursor, right? If it's the same handle value you had before, then I think it's reasonable to assume it looks the same, too. If the cursor looks different, it will have a different handle value.

对于标准系统游标肯定是正确的.如果您正在记录的应用程序正在运行时正在创建新的游标,则也许它将能够更新当前游标的外观,而无需在操作系统中实际创建新的游标对象(因此保持相同的句柄值),但我认为这不太可能,尤其是因为SetCursor会在光标未更改时立即退出,并且我希望API函数不会执行您要避免的图形比较,任何一个.它只是比较HCursor值.

That should certainly be true for the standard system cursors. If the application you're recording is creating new cursors while it's running, then maybe it would be able to update the appearance of the current cursor without actually making a new cursor object in the OS (and thus keeping the same handle value), but I don't think that's likely, especially since SetCursor exits immediately when the cursor hasn't changed, and I expect the API function doesn't do the graphical comparison you're trying to avoid, either. It just compares the HCursor value.

这篇关于如何判断鼠标指针图标是否已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆