码迷,mamicode.com
首页 > Windows程序 > 详细

Win8环境WPF打开和关闭软键盘

时间:2015-01-16 16:32:54      阅读:1157      评论:0      收藏:0      [点我收藏+]

标签:

代码如下:

public class KeyBoardHelper
    {
        #region 键盘控制
        /// <summary>
        /// 显示键盘
        /// </summary>
        public static void ShowInputPanel()
        {
            string path = @"C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe";
            string path32 = @"C:\Program Files (x86)\Common Files\Microsoft Shared\Ink\TabTip32.exe";
            if (File.Exists(path))
            {
                Process.Start(path);
            }
            else if (File.Exists(path32))
            {
                Process.Start(path32);
            }
        }

        #region import 软键盘
         [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        private const Int32 WM_SYSCOMMAND = 274;
        private const UInt32 SC_CLOSE = 61536;
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
        #endregion
       /// <summary>
        ///  隐藏屏幕键盘
       /// </summary>
        public static void HideInputPanel()
        {
            IntPtr TouchhWnd = new IntPtr(0);
            TouchhWnd = FindWindow("IPTip_Main_Window", null);
            if (TouchhWnd == IntPtr.Zero)
                return;
            PostMessage(TouchhWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
        }
        #endregion 
    }

 

Win8环境WPF打开和关闭软键盘

标签:

原文地址:http://www.cnblogs.com/wangjinming/p/4228763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!