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

平板下windows程序调用软键盘的办法

时间:2014-05-17 15:25:14      阅读:1105      评论:0      收藏:0      [点我收藏+]

标签:class   c   tar   ext   http   int   



http://stackoverflow.com/questions/21140852/start-tabtip-with-numpad-view-open         
 
 
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
 
 
        private static void KillTabTip()
        {
            // Kill the previous process so the registry change will take effect.
            var processlist = Process.GetProcesses();
 
            foreach (var process in processlist.Where(process => process.ProcessName == "TabTip"))
            {
                process.Kill();
                break;
            }
        }
 
        public static void ShowTouchKeyboard(bool isVisible, bool numericKeyboard)
        {
            if (isVisible)
            {
                const string keyName = "HKEY_CURRENT_USER\\Software\\Microsoft\\TabletTip\\1.7";
 
                var regValue = (int)Registry.GetValue(keyName, "KeyboardLayoutPreference", 0);
                var regShowNumericKeyboard = regValue == 1;
 
                // Note: Remove this if do not want to control docked state.
                var dockedRegValue = (int)Registry.GetValue(keyName, "EdgeTargetDockedState", 1);
                var restoreDockedState = dockedRegValue == 0;
 
                if (numericKeyboard && regShowNumericKeyboard == false)
                {
                    // Set the registry so it will show the number pad via the thumb keyboard.
                    Registry.SetValue(keyName, "KeyboardLayoutPreference", 1, RegistryValueKind.DWord);
 
                    // Kill the previous process so the registry change will take effect.
                    KillTabTip();
                }
                else if (numericKeyboard == false && regShowNumericKeyboard)
                {
                    // Set the registry so it will NOT show the number pad via the thumb keyboard.
                    Registry.SetValue(keyName, "KeyboardLayoutPreference", 0, RegistryValueKind.DWord);
 
                    // Kill the previous process so the registry change will take effect.
                    KillTabTip();
                }
 
                // Note: Remove this if do not want to control docked state.
                if (restoreDockedState)
                {
                    // Set the registry so it will show as docked at the bottom rather than floating.
                    Registry.SetValue(keyName, "EdgeTargetDockedState", 1, RegistryValueKind.DWord);
 
                    // Kill the previous process so the registry change will take effect.
                    KillTabTip();
                }
 
                Process.Start("c:\\Program Files\\Common Files\\Microsoft Shared\\ink\\TabTip.exe");
            }
            else
            {
                var win8Version = new Version(6, 2, 9200, 0);
 
                if (Environment.OSVersion.Version >= win8Version)
                {
                    const int wmSyscommand = 274;
                    const uint scClose = 61536;
                    IntPtr keyboardWnd = FindWindow("IPTip_Main_Window", null);
                    PostMessage(keyboardWnd, wmSyscommand, (int)scClose, 0);
                }
            }
        }
 

平板下windows程序调用软键盘的办法,布布扣,bubuko.com

平板下windows程序调用软键盘的办法

标签:class   c   tar   ext   http   int   

原文地址:http://www.cnblogs.com/firesword/p/3730773.html

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