locked
Windows 10 Tablet Mode: Why doesn't winforms TextBox show the onscreen keyboard if getting the focus? RRS feed

  • Question

  • In Windows 10 tablet-mode, other winforms controls do pop-up the onscreen-keyboard if getting the focus, like RichTextBox or ComboBox. If entering the TextBox, nothing happens.

    If one opens the onscreen Keyboard manually by clicking the taskbar icon, the textbox content can be edited.

    If creating a little MFC application with a textbox, the onscreen keyboard is also opened automatically if entering.

    So what's wrong with the winforms TextBox implementation? Is there any window-style that must be set addionally?

    Thanks for any idea to reolve this problem!

    Friday, October 23, 2015 8:23 AM

Answers

  • After a lot of search, we found a simple and global solution.

    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); 
    This code seems stupid, but it does it! Don't ask me why at the moment.


    It is sufficient to call this once for your main window. All child windows and dialogs which are opened after that will now behave right if tipping on a textbox.
    I only tested Win 10 until now. I think the code above must be executed depending on the operation system.

    One last problem is still left: The NumericUpDown-control still doesn't open the keyboard. But that's a minor problem.

    Thursday, October 29, 2015 11:19 AM

All replies

  • So what's wrong with the winforms TextBox implementation? Is there any window-style that must be set addionally?

    Thanks for any idea to reolve this problem!

    Per my understanding, On screen keyboard was controlled by Win 10 system and has not related to TextBox control in WinForm.

    For this issue, there is an easy work around to pop up OSK in WinForm application. Find the sitting directory of OSK.exe and call it in TextBox click event or any other events you want.

     Process.Start(@"C:\Windows\System32\osk.exe");

    You can refer to the following link to find more info about this work around. http://stackoverflow.com/questions/9298515/keyboard-on-the-screen-in-winforms

    I hope it helps.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 26, 2015 6:00 AM
  • Thanks for your answer.

    Surely, one can force showing the Win10 on-screen keyboard (tabtip.exe) by controlling the gotFocus and lostFocus events of the textbox, as explained in "Open and close tabtip.exe from a VB.net 2010 application".
    But as as one can see with RichTextBox, there is a build-in mechanism for showing the onscreen-keyboard, probably on a deep system-level. I expect the same for the textbox.
    If programming it manually, there is a risk of compatibility issues in future. For example: If someone opened the "old" osk.exe, now the application will not behave like other Win10 apps, which use tabtip.exe.
    I would like to know which setting in System.Windows.Forms.Textbox prevents the system from opening the keyboard.

    Tuesday, October 27, 2015 12:39 PM
  • Thanks for your answer.

    Surely, one can force showing the Win10 on-screen keyboard (tabtip.exe) by controlling the gotFocus and lostFocus events of the textbox, as explained in "Open and close tabtip.exe from a VB.net 2010 application".
    But as as one can see with RichTextBox, there is a build-in mechanism for showing the onscreen-keyboard, probably on a deep system-level. I expect the same for the textbox.
    If programming it manually, there is a risk of compatibility issues in future. For example: If someone opened the "old" osk.exe, now the application will not behave like other Win10 apps, which use tabtip.exe.
    I would like to know which setting in System.Windows.Forms.Textbox prevents the system from opening the keyboard.

    I don't think there is a method or property in TextBox doing what you want. I go through the following page but with no luck. http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/TextBox.cs,42dbcbcf446ee130,references

    >> If someone opened the "old" osk.exe, now the application will not behave like other Win10 apps, which use tabtip.exe

    You cloud check if there is tabtip.exe in user's computer and execute that exe. If not, execute osk.exe

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 29, 2015 9:24 AM
  • After a lot of search, we found a simple and global solution.

    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); 
    This code seems stupid, but it does it! Don't ask me why at the moment.


    It is sufficient to call this once for your main window. All child windows and dialogs which are opened after that will now behave right if tipping on a textbox.
    I only tested Win 10 until now. I think the code above must be executed depending on the operation system.

    One last problem is still left: The NumericUpDown-control still doesn't open the keyboard. But that's a minor problem.

    Thursday, October 29, 2015 11:19 AM
  • Thank you for sharing a simple and global solution.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 2, 2015 8:30 AM
  • I have added the code to a simple Winforms VB.Net application using visual studio 2012 and .net 4.5 and it works ok on Windows 10 on a Lenovo Yoga 500.

    The steps were:

       - Insert a reference to UIAutomationClient.dll to the project

       - Add the following line to the form load event:

            Dim asForm = System.Windows.Automation.AutomationElement.FromHandle(Me.Handle)

    Keyboard pops for simple textboxes.

    Friday, January 15, 2016 10:49 AM
  • While not a strict answer to why the TextBox does not support the on screen keyboard in Windows 10, you can avoid the entire problem by using a RichTextBox instead of the TextBox.  The RichTextBox supports the onscreen keyboard in the way you are expecting.
    Friday, June 16, 2017 8:15 PM