After killing the process for TabletKeyboard(TabTip.exe) application doesn't bring back to its original size in wpf

后端 未结 2 394
遇见更好的自我
遇见更好的自我 2020-12-16 06:10

I have a wpf application which runs on the windows 8 tablet . And in order to bring the keyboard for typing when the focus is on any TextBox.

I am invok

2条回答
  •  旧时难觅i
    2020-12-16 06:43

    Abin - you asked about closing the keyboard window rather than killing the process. That's what I'm doing in a WPF app and by closing the window, my main application's window will resize as expected. A quick console app to demonstrate hiding the keyboard is here (note that this assumes you're using the keyboard in docked mode rather than the floating minimal mode):

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TabTipTest
    {
        class Program
        {
            [DllImport("user32.dll")]
            public static extern IntPtr FindWindow(String sClassName, String sAppName);
    
            [DllImport("user32.dll")]
            public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
    
            /// 
            /// The command for a user choosing a command from the Window menu (see http://msdn.microsoft.com/en-gb/library/windows/desktop/ms646360(v=vs.85).aspx).
            /// 
            public const int WM_SYSCOMMAND = 0x0112;
    
            /// 
            /// Closes the window.
            /// 
            public const int SC_CLOSE = 0xF060;
    
            static void Main(string[] args)
            {
                HideKeyboard();
            }
    
            /// 
            /// Gets the window handler for the virtual keyboard.
            /// 
            /// The handle.
            public static IntPtr GetKeyboardWindowHandle()
            {
                return FindWindow("IPTip_Main_Window", null);
            }
    
            /// 
            /// Hides the keyboard by sending the window the close command.
            /// 
            public static void HideKeyboard()
            {
                IntPtr keyboardHandle = GetKeyboardWindowHandle();
    
                if (keyboardHandle != IntPtr.Zero)
                {
                    SendMessage(keyboardHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
                }
            }
        }
    }
    

提交回复
热议问题