鼠标指针呈现 [英] Mouse pointer renderer

查看:163
本文介绍了鼠标指针呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C创建软件++针对Windows 7(使用Windows API),允许在同一台PC上第二个鼠标指针,所以我的问题是Windows的一部分巫正在处理的鼠标指针的呈现?
我认为,理解它是如何工作将让我模仿它,以使第二个鼠标指针。
谢谢你。

I'm thinking about creating a software with c++ targeting Windows 7 (using Windows api) that allows a second mouse pointer on the same PC, so my question is witch part of Windows is handling the rendering of the mouse pointer? I believe that understanding how it actually works will allow me to imitate it in order to render a second mouse pointer. Thank you.

推荐答案

窗口的窗口系统只支持一个真正的光标:它是2D图形芯片组的低级别的功能(这就是为什么光标不出现在截图)。窗户留出视频存储器的一个单独的区域,保存光标的位图:用于α-透明任一个DDB(依赖于设备的位图)与一个AND /异或信道(对索引的不透明度和颜色反转)或32bpp的RGBA表面光标(这是作秀光标影子功能是如何实现的)。我的理解是,光标被应用到实际的输出图像,因为它是由输出设备扫描(例如在DAC为任何DVI和HDMI使用VGA输出或),所以它永远不会在帧缓冲区中存在 - 这是如何光标之前我们已经合成窗口管理器的日子,也不必要求应用程序重新绘制自己所在的光标已经工作。

Windows's windowing system only supports a single "true" cursor: it is a low-level feature of the 2D graphics chipset (which is why the cursor doesn't appear in screenshots). Windows sets aside a separate area of video memory that holds the bitmap of the cursor: either a DDB (device-dependent bitmap) with an AND/XOR channel (for indexed opacity and color inversion), or a 32bpp RGBA surface for alpha-transparent cursors (which is how the "show cursor shadow" feature is implemented). My understanding is that the cursor is applied to the actual output image as it is "scanned" by the output device (e.g. the DAC for VGA-out or whatever DVI and HDMI use), so it never exists in the framebuffer - this is how the cursor worked in the days before we had composited window managers and without having to ask applications to redraw themselves where the cursor had been.

使用对光标这个特殊特技也有必要保持延迟为最小。如果你写,吸引到窗户表面上的程序(例如与GDI甚至可以通过OpenGL或Direct3D的),你会看到它滞后几毫秒的真正光标后,这是noticable用户很容易(这就是为什么现代RTS游戏使用,而不是重新实现它自己)这个硬件光标功能。

Using this special trick for the cursor is also necessary to keep latency to a minimum. If you write a program that draws to a windows surface (e.g. with GDI or even through OpenGL or Direct3D) you'll see it lags behind the real cursor by a few miliseconds and this is noticable to users very easily (which is why modern RTS games use this hardware cursor feature instead of reimplementing it themselves).

有没有办法来扩展这个功能,我所知道的 - 你将不得不拆卸修改Windows和图形驱动程序来实现绘制多个游标的能力之神

There is no way to extend this feature that I'm aware of - you will have to be a god of disassembly to modify Windows and graphics drivers to implement the ability to draw multiple cursors.

这就是事情的presentation一面。对于多个游标实际应用层面的支持也是有难度的 - 记住,光标移动对应于不同的鼠标相关的窗口消息被发送到hWnds。与两个光标的问题是,这些消息会冲突,尽管理论上它应该工作,只要它们是序列化到单个队列正常。将会有一个应用程序的问题,很多人都会有这样的假设,例如,只有一个单一的控制,可在悬停状态下一次,如果你有多个游标,那么应用程序只能尊重最近光标消息。

That's the presentation side of things. Actual application-level support for multiple cursors is also tricky - remember that cursor movement corresponds to various Mouse-related window Messages being sent to hWnds. The problem with two cursors is that these messages will conflict, though theoretically it should work provided they're serialized into a single queue properly. There will be problems with applications, many will make the assumption that, for example, only a single control can be in the Hover state at once, if you have multiple cursors then the application would only respect the most recent cursor message.

我可能会建议看Windows的支持多点触控,在Windows 7中,它不支持多个同时游标,虽然它是为手指而不是鼠标出台。

I might suggest looking at Windows' multi-touch support, introduced in Windows 7, where it does support multiple simultaneous "cursors", though it is intended for fingers, not mice.

这篇关于鼠标指针呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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