如何使用雙顯示器應用程序解決此焦點問題?

[英]How to solve this focus problem with a dual monitor application?


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.

我們有一個使用雙顯示器設置的應用程序 - 用戶A將與監視器1一起使用,用戶B將同時使用監視器2。監視器2是觸摸屏設備。

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.

現在,問題是,當用戶A在他的屏幕中輸入內容時,如果用戶B試圖做某事,用戶A將最終失去他窗口的焦點,這是災難性的。

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?

即使用戶B對Monitor 2執行某些操作,在Monitor 1中保持對窗口的關注可能是一個很好的解決方案?

5 个解决方案

#1


It is possible with some elbow grease. Paste this code in the form that you show on the touch screen:

一些彎頭油脂是可能的。將此代碼粘貼到您在觸摸屏上顯示的表單中:

protected override CreateParams CreateParams {
  get {
    const int WS_EX_NOACTIVATE = 0x08000000;
    CreateParams param = base.CreateParams;
    param.ExStyle |= WS_EX_NOACTIVATE;
    return param;
  }
}

That makes sure that the form won't steal the focus from the main form. Make it look like this:

這確保了表單不會從主表單中竊取焦點。看起來像這樣:

  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
      Thread t = new Thread(SecondMonitor);
      t.IsBackground = true;
      t.SetApartmentState(ApartmentState.STA);
      t.Start();
    }
    private void SecondMonitor() {
      Form2 f2 = new Form2();
      f2.StartPosition = FormStartPosition.Manual;
      f2.Left = 800;   // Use Screen class here...
      f2.ShowDialog();
    }

#2


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.

對我來說,聽起來你可能想要2台PC ......或者可能在PC上托管VM,並通過USB視頻“卡”讓VM訪問第二台顯示器(不是很合適的術語)。最現代的VM允許USB傳輸。

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).

大多數情況下,多頭顯示器要么用於為單個用戶提供大量屏幕空間,要么用作僅顯示設施(例如,通過大型基礎架構設置顯示實時網絡/服務器統計信息)。

#3


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.

您可以添加功能來過濾每個設備的輸入,並將每個不同的輸入發送到一組單獨的控件,但我想這需要一些驅動程序級別的工作。

#4


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.

我從未使用過觸摸屏,但我傾向於認為它們像鼠標一樣工作。所以,如果這是真的,我認為你可以使用Windows鈎子來捕獲事件。如果事件來自鍵盤(我假設是單一的),請將其指向您的第一個窗口。如果事件來自鼠標,請檢查其坐標(或設備ID,如果有,我不知道)。如果它在您的第一個窗口內,則直接輸入它。如果它在第二個屏幕中,則直接輸入到第二個窗口。

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).

編輯:當然,您需要確定哪個應用程序應在第一個屏幕上接收消息。我猜Z-order可以提供幫助,除非用戶打開一些on-top應用程序。跟蹤OnFocus消息(或類似的東西)以跟蹤哪個應用程序正在獲得焦點(不包括您的其他應用程序)可能更好。

(Comments explaining any deficencies with this method are very welcome!)

(非常歡迎用這種方法解釋任何缺陷的評論!)

#5


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?

你能不假裝嗎?有一個窗口跨越兩個監視器,並作為您正在使用的窗口的容器?


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2008/12/24/1db80985669e861ba65f265e86fcf675.html



 
  © 2014-2022 ITdaan.com 联系我们: