在MFC中捕获鼠标指针形状更改事件 [英] Capturing Mouse pointer shape change event in MFC

查看:323
本文介绍了在MFC中捕获鼠标指针形状更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Windows应用程序,该应用程序需要鼠标指针形状更改通知.我已经进行了彻底搜索,但找不到满意的解决方案.我想收到有关光标形状更改及其更改的光标类型的通知.

I am writing a windows application which requires mouse pointer shape change notification. I have searched thoroughly but could not find a satisfactory solution. I want to receive a notification for cursor shape change as well as the type of cursor to which it has changed.

通过搜索,我知道我将必须在每个进程中安装一个钩子并捕获WM_SETCURSOR事件,但是捕获此消息并不能为我提供完整的信息.所以,如果有人可以帮忙,请指导我

From the search I came to know that I will have to install a hook in every process and capture WM_SETCURSOR event but capturing this message does not give me full information. So please guide me if anybody can help

推荐答案

您可以使用GetCursorGetCursorInfo获取当前光标的句柄.

You can get the handle to the current cursor with GetCursor or GetCursorInfo.

问题是要知道句柄所指向的光标.我认为没有反向查找"功能,因此您必须通过将您的句柄与LoadCursor返回的句柄比较不同的可能值来实现它.

The problem is to know which cursor the handle refers to. I don't think there's a "reverse find" function, so you would have to implement it by comparing your handle with the one returned by LoadCursor for the different possible values.

幸运的是,文档是这样说的:

Fortunately, the docs say this:

LoadCursor函数仅在没有游标资源的情况下才加载游标资源 已加载;否则,它将检索现有句柄 资源.

The LoadCursor function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to the existing resource.

这篇关于在MFC中捕获鼠标指针形状更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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