User32.dll 鼠标事件

发布于 2024-12-23 23:41:33 字数 417 浏览 1 评论 0原文

我正在寻找一个光标控制类,我正在尝试使其适应我的程序。我让它按照我的意愿工作,但我有点不确定这些数字在这种情况下意味着什么。任何人都可以解释 0x01 等的含义吗?

    private const int MouseEventMove = 0x01;
    private const int MouseEventLeftDown = 0x02;
    private const int MouseEventLeftUp = 0x04;
    private const int MouseEventRightDown = 0x08;
    private const int MouseEventRightUp = 0x10;
    private const int MouseEventAbsolute = 0x8000;

谢谢。

I'm looking at a cursor control class that I'm trying to adapt for my program. I have it working as I wish, but I was unsure a little on what these numbers mean in this case. Can anybody shed any light on what the 0x01 etc mean.

    private const int MouseEventMove = 0x01;
    private const int MouseEventLeftDown = 0x02;
    private const int MouseEventLeftUp = 0x04;
    private const int MouseEventRightDown = 0x08;
    private const int MouseEventRightUp = 0x10;
    private const int MouseEventAbsolute = 0x8000;

Thanks.

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

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

发布评论

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

评论(2

拧巴小姐 2024-12-30 23:41:33

这些是您传递给 mouse_event() Windows API 函数。标志值在 WinUser.h Windows SDK 头文件中声明。正如链接的 MSDN 文章中所述,您不应再使用此函数。

访问 pinvoke.net 以获取 SendInput() 的正确声明。

Those are the values of the MOUSEEVENTF flags you pass to the mouse_event() Windows api function. The flag values are declared in the WinUser.h Windows SDK header file. As noted in the linked MSDN article you shouldn't be using this function anymore.

Visit pinvoke.net to get the proper declaration for SendInput().

雪化雨蝶 2024-12-30 23:41:33

这些是Flag枚举。
它们每个都被赋予一个 2 次方的值,因此对于任何组合值,设置哪个标志都不会产生歧义。

来自 MSDN:

标志枚举用于屏蔽位字段并按位进行
比较。它们是多个时使用的正确设计
可以同时指定枚举值。

http://msdn.microsoft.com/en-us/library/ms229062.aspx

在您的特定情况下,枚举似乎描述了正在发生的鼠标事件类型。

编辑:正如 Hans 指出的那样,这在技术上不是一个枚举,而是一组 const int 定义,尽管出于所有实际目的,我认为它充当枚举 - 为积分提供人类可读的标签价值。有没有更合适的名字呢?

These are Flag enumerations.
They are each given a value in powers of 2, so for any combined value, there will be no ambiguity about which of the flags are set.

From MSDN:

Flags enumerations are used for masking bit fields and doing bitwise
comparisons. They are the correct design to use when multiple
enumeration values can be specified at the same time.

http://msdn.microsoft.com/en-us/library/ms229062.aspx

In your particular case it seems that the enumeration describes what type of mouse event is occurring.

Edit: As Hans points out, this is not technically an enumeration, but a group of const int definitions, though for all practical purposes I feel it serves as an enumeration - giving a human readable label for an integral value. Is there a more suitable name for this?

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