秀&从 WPF 隐藏 Windows 8 屏幕键盘 [英] Show & hiding the Windows 8 on screen keyboard from WPF

查看:28
本文介绍了秀&从 WPF 隐藏 Windows 8 屏幕键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 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 FilesCommon FilesMicrosoft SharedinkTabTip.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();
}

希望对你有帮助.

这篇关于秀&从 WPF 隐藏 Windows 8 屏幕键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆