平板下windows程式調用軟鍵盤的辦法

來源:互聯網
上載者:User

標籤: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);                }            }        } 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.