I'm writing a WPF application for a Windows 8 tablet. It's full windows 8 and not ARM/RT.
When the user enters a textbox I show the on screen keyboard using the following code:
System.Diagnostics.Process.Start(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe");
This works fine however I don't know how to hide the keyboard again?
Anybody know how to do this?
Also, is there any way I can resize my application so that focused control is moved up when the keyboard appears? A bit like it does for a windows RT application.
Many Thanks
I could successfully close onscreen keyboard with the following C# code.
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
private void closeOnscreenKeyboard()
{
// retrieve the handler of the window
int iHandle = FindWindow("IPTIP_Main_Window", "");
if (iHandle > 0)
{
// close the window using API
SendMessage(iHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
}
private void Some_Event_Happened(object sender, EventArgs e)
{
// It's time to close the onscreen keyboard.
closeOnscreenKeyboard();
}
I hope this will help you.
I open-sourced my project to automate everything concerning TabTip integration in WPF app.
You can get it on nuget, and after that all you need is a simple config in your apps startup logic:
TabTipAutomation.BindTo<TextBox>();
You can bind TabTip automation logic to any UIElement. Virtual Keyboard will open when any such element will get focus, and it will close when element will lose focus. Not only that, but TabTipAutomation will move UIElement (or Window) into view, so that TabTip will not block focused element.
For more info refer to the project site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With