Automatically pop up tablet touch keyboard on WinForms input focus

前端 未结 5 1557
南旧
南旧 2020-12-24 01:11

When I run a WinForms (or Delphi, see at the end) application on Windows 10 in a tablet mode, a touch keyboard does not pop up automatically, when an input box is focused.

5条回答
  •  梦毁少年i
    2020-12-24 01:54

    The root cause seems to be that Winforms' textBox is not an AutomationElement, while the rest of the mentioned controls (ComboBoxes etc) are.

    Quoting Markus von und zu Heber's accepted answer here:

    We found it in the article "Automatic Touch Keyboard for TextBoxes in WPF Applications on Windows 8+", but it also works very good (and even easier!) for winforms. Thank you, Dmitry Lyalin!

    1. Insert a reference to UIAutomationClient.dll to your project

    2. In the form-load-handler of the application's main window, insert the following code:

      var asForm = System.Windows.Automation.AutomationElement.FromHandle(this.Handle);
      

提交回复
热议问题