public static InputPane GetForWindow(IntPtr hWnd)
        {
            IInputPaneInterop inputPaneInterop = (IInputPaneInterop)InteropHelper.GetActivationFactory <IInputPaneInterop>(typeof(InputPane));
            Guid guid = typeof(InputPane).GUID;

            return(inputPaneInterop.GetForWindow(hWnd, ref guid));
        }
        public static InputPane GetForWindow(IntPtr hWnd)
        {
            IInputPaneInterop inputPaneInterop = (IInputPaneInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(InputPane));
            Guid guid = typeof(InputPane).GUID;

            return(inputPaneInterop.GetForWindow(hWnd, ref guid));
        }
        /// <summary>
        /// TouchKeyboardEventManager
        /// </summary>
        /// <param name="handle">Need the HWND for the native interop call into IInputPaneInterop</param>
        internal TouchKeyboardEventManager(IntPtr handle)
        {
            inputPaneType = Type.GetType(InputPaneTypeName);

            // Get and cast an InputPane COM instance
            inputPaneInterop = WindowsRuntimeMarshal.GetActivationFactory(inputPaneType) as IInputPaneInterop;

            touchKeyboardSupported = inputPaneInterop != null;

            if (touchKeyboardSupported)
            {
                // Get the actual input pane for this HWND
                inputPanel = inputPaneInterop.GetForWindow(handle, typeof(IInputPane2).GUID);
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (inputPanel != null)
                    {
                        Marshal.FinalReleaseComObject(inputPanel);

                        inputPanel = null;
                    }

                    if (inputPaneInterop != null)
                    {
                        Marshal.FinalReleaseComObject(inputPaneInterop);

                        inputPaneInterop = null;
                    }
                }
            }

            disposed = true;
        }