Пример #1
0
        void InitializeIME()
        {
            if (imeState.HwndSource != null)
            {
                return;
            }
            imeState.HwndSource = PresentationSource.FromVisual(textView.VisualElement) as HwndSource;
            if (imeState.HwndSource == null)
            {
                return;
            }

            Debug.Assert(imeState.Context == IntPtr.Zero);
            Debug.Assert(imeState.HWND == IntPtr.Zero);
            Debug.Assert(imeState.OldContext == IntPtr.Zero);
            if (textView.Options.DoesViewProhibitUserInput())
            {
                imeState.Context = IntPtr.Zero;
                imeState.HWND    = IntPtr.Zero;
            }
            else
            {
                imeState.HWND    = ImeState.ImmGetDefaultIMEWnd(IntPtr.Zero);
                imeState.Context = ImeState.ImmGetContext(imeState.HWND);
            }
            imeState.OldContext = ImeState.ImmAssociateContext(imeState.HwndSource.Handle, imeState.Context);
            imeState.HwndSource.AddHook(WndProc);
            TfThreadMgrHelper.SetFocus();
        }
Пример #2
0
 void StopIME(bool cancelCompositionString)
 {
     if (imeState.HwndSource == null)
     {
         return;
     }
     if (cancelCompositionString)
     {
         CancelCompositionString();
     }
     ImeState.ImmAssociateContext(imeState.HwndSource.Handle, imeState.OldContext);
     ImeState.ImmReleaseContext(imeState.HWND, imeState.Context);
     imeState.HwndSource.RemoveHook(WndProc);
     imeState.Clear();
     textCaretLayer.SetImeStarted(false);
 }