如何通过双显示器应用程序解决这个焦点问题?
我们有一个使用双显示器设置的应用程序 - 用户 A 将使用显示器 1,用户 B 将同时使用显示器 2。 显示器 2 是触摸屏设备。
现在的问题是,当用户 A 在屏幕上输入某些内容时,如果用户 B 尝试执行某些操作,用户 A 最终将失去窗口的焦点,这是灾难性的。
即使用户 B 对监视器 2 执行某些操作,也可以将焦点保留在监视器 1 中的窗口上,这可能是一个好的解决方案吗?
We have an application that uses a dual monitor setup - User A will work with Monitor 1, and user B will work with Monitor 2 simultaneously. Monitor 2 is a touch screen device.
Now, the problem is, when User A types something in his screen, if User B tries to do something, User A will end up in losing the focus from his window, which is disastrous.
What might be a good solution to preserve the focus on the window in Monitor 1, even if User B do something with Monitor 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
用一些肘部润滑脂是可能的。 将此代码粘贴到触摸屏上显示的表单中:
这可确保表单不会窃取主表单的焦点。 让它看起来像这样:
It is possible with some elbow grease. Paste this code in the form that you show on the touch screen:
That makes sure that the form won't steal the focus from the main form. Make it look like this:
对我来说,听起来您可能需要 2 台 PC……或者可能在 PC 上托管一个虚拟机,并让虚拟机通过 USB 视频“卡”(不太正确的术语)访问第二台显示器。 大多数现代虚拟机都允许 USB 传输。
大多数时候,多头显示器要么用于为单个用户提供大量屏幕空间,要么用作仅显示的设施(例如,在大型基础设施设置上显示实时网络/服务器统计信息)。
To me, it sounds like you might want 2 PC's... or maybe host a VM on the PC, and give the VM access to the second monitor via a USB video "card" (not quite the right term). Mmost modern VM's allow USB transfer.
Most times, multi-head displays are either used to give a single user lots of screen real-estate, or as a display-only facility (for example, showing live network/server stats over a large infrastructure setup).
我找不到一种方法可以允许两个用户同时访问同一桌面环境而不遇到焦点问题。 如果您考虑一下,允许两个应用程序(或者在这种情况下,一个具有两个用户“区域”的应用程序总是会出现问题,因为应用程序需要尝试跟踪哪个输入设备最近与哪个区域的哪个区域一起工作) 。
您可能可以添加功能来过滤每个设备的输入并将每个不同的输入发送到一组单独的控件,但我认为这需要一些驱动程序级别的工作
I can';t see a way to allow two users to access the same desktop environment simultaneously without running into focus issues. If you think about it, allowing two applications (or in this case, one app with two user "areas" will always be problematic, since the application would need to attempt to keep track of which input device worked most recently with which area of the screen.
You might be able to add functionality to filter inputs per device and send each distinct input to a separate set of controls, but I imagine that would require some driver-level work.
我从未使用过触摸屏,但我倾向于认为它们在某种程度上像鼠标一样工作。 因此,如果这是真的,我认为您也许可以使用 Windows 挂钩来捕获事件。 如果事件来自键盘(我假设是单个键盘),请将其定向到您的第一个窗口。 如果事件来自鼠标,请检查其坐标(或者可能是设备 ID,如果有的话,我不知道)。 如果它在您的第一个窗口内,请直接输入。 如果在第二个屏幕中,请直接输入到第二个窗口。
如果屏幕不像鼠标,我想你会找到另一种方法来为它放置一个钩子。
我不知道这是否有效。 这只是一个概念性的想法。
编辑:当然,您需要确定哪个应用程序应在第一个屏幕上接收消息。 我想 Z 顺序可以提供帮助,除非用户打开一些顶部应用程序。 最好跟踪 OnFocus 消息(或类似的消息)以跟踪哪个应用程序获得焦点(不包括您的其他应用程序)。
(非常欢迎评论解释此方法的任何缺陷!)
I never worked with touch screens, but I am inclined to think they work somehow like a mouse. So if this is true, I think you may be able to use Windows hooks to capture events. If the event is from the keyboard (which I assume is single), direct it to your first window. If the event is from the mouse, check its coordinates (or maybe device ID if there is one, I don't know). If it is within your first window, direct input to it. If it is in the second screen, direct input to your second window.
If the screen is not like a mouse, I guess you'll find another way to put a hook for it.
I don't know whether this would work. It's just a conceptual idea.
Edit: Of course you need to identify which application should receive the messages on the first screen. I guess Z-order can help, unless the user opens some on-top application. It may be better to track OnFocus messages (or something similar) to keep track of which application is getting focus (excluding your other app).
(Comments explaining any deficencies with this method are very welcome!)
能不能别造假啊? 是否有一个窗口跨越两个显示器并充当您正在使用的窗口的容器?
Can you not fake it? Have one window that spans both monitors and acts as a container for the windows that you're working with?