Skip to main content
 首页 » 编程设计

c#之如何在Windows 8 Metro 界面上方绘制

2024年02月20日12lonelyxmas

我想绘制位于所有其他界面之上的图形,包括 Windows 8 新主屏幕。你会怎么做?在 Windows 7 及以下版本中,它就像显示一个透明的全屏窗口一样简单,但现在由于桌面与操作系统的其余部分分离,所以不再可能了。

原因是我需要显示两个独立于 Windows 鼠标光标的光标。我正在为 Wii Remote 开发多点触控模拟软件(使用传感器条指针),目前我只是设置光标位置并通过摇动 +1 和 -1 像素将其唤醒。但它会干扰触摸,所以我在使用触摸模拟时必须禁用它。它目前有效,但我想添加多点触控支持,以便您可以使用 Wii Remote 进行缩放和旋转。触摸功能已准备就绪,但您希望在按住一个触摸点并使用 Wii Remote 选择另一个触摸点时看到光标,而在按住第一个触摸点时,Windows 光标无法移动到其他任何地方,因为它坚持接触点。

我已经了解了如何通过为屏幕获取一个 Graphics 对象来直接在屏幕上绘制,但它不起作用,因为它完全不受管理,因此图形保持可见,直到其他东西刷新该区域。

那么,有什么建议吗?

涉及的项目称为 Touchmote,可在 touchmote.net 上以源代码和可安装测试版的形式获得。

请您参考如下方法:

  1. Demand the UIAccess integrity level in application manifest 通过在 requestedPrivileges 属性中指定 UIAccess=”true”。
  2. 使窗口最顶层(通过 SetWindowPos 更改位置或在 WinForms/WPF 中设置 TopMost 属性)
  3. Sign the application using a digital certificate that chains up to a trusted root in the local machine Trusted Root Certification Authorities certificate store .
  4. 直接从 not from a debugger 运行(即 a secure location in the file system )。之后您可以附加调试器。

请注意,这会使您的应用程序运行提升,您可能有 issues when you need to connect to your application from a lower integrity level 。