问题描述
我正在为Windows 8平板电脑编写WPF应用程序.它是完整的Windows 8,而不是ARM/RT.
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?
有人知道该怎么做吗?
还有,我有什么方法可以调整应用程序的大小,以便在出现键盘时向上移动聚焦的控件?有点像Windows RT应用程序.
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.
非常感谢
推荐答案
我可以使用以下C#代码成功关闭屏幕键盘.
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.
这篇关于显示和从WPF隐藏屏幕键盘上的Windows 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!