如何禁用虚拟键盘支持我的应用程序



由于我有内置键盘,所以我不需要在我的WPF应用程序中使用系统范围的虚拟键盘。我为文本框设置了IsHitTestVisible="False",但虚拟键盘缩略图仍然可见。

我在这里回答了类似的问题,但这是针对windows mobile 6.5;但我猜它也会在win7上工作…下面是隐藏键盘图标的代码:

//Declare Win API method
[DllImport("coredll.dll", EntryPoint="FindWindowW", SetLastError=true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName)
[DllImport("coredll.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("coredll.dll", SetLastError = true)]
    internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
//Call FindWindow and SetWindowPos to hide keyboard icon
IntPtr hWnd = FindWindow(Nothing, "MS_SIPBUTTON");
SetWindowPos(hWnd, 1, 0, 0, 0, 0, &H80);

请看我的回答。通过设置注册表值,您可以为某个应用程序禁用屏幕上的键盘缩略图

如果您想要在特定方法之后隐藏虚拟键盘,您可以这样做:focus ();

最新更新