void CreateContext() { hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); if (hwndSource != null) { if (isReadOnly) { defaultImeWnd = IntPtr.Zero; currentContext = IntPtr.Zero; } else { defaultImeWnd = ImeNativeWrapper.ImmGetDefaultIMEWnd(IntPtr.Zero); currentContext = ImeNativeWrapper.ImmGetContext(defaultImeWnd); } previousContext = ImeNativeWrapper.ImmAssociateContext(hwndSource.Handle, currentContext); hwndSource.AddHook(WndProc); // UpdateCompositionWindow() will be called by the caret becoming visible var threadMgr = ImeNativeWrapper.GetTextFrameworkThreadManager(); if (threadMgr != null) { // Even though the docu says passing null is invalid, this seems to help // activating the IME on the default input context that is shared with WPF threadMgr.SetFocus(IntPtr.Zero); } } }
void CreateContext() { ClearContext(); // clear old context if necessary if (!textArea.Options.EnableImeSupport) { return; } hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); if (hwndSource != null) { //currentContext = ImeNativeWrapper.ImmCreateContext(); //previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext); currentContext = ImeNativeWrapper.GetContext(hwndSource); hwndSource.AddHook(WndProc); // UpdateCompositionWindow() will be called by the caret becoming visible var threadMgr = ImeNativeWrapper.GetTextFrameworkThreadManager(); if (threadMgr != null) { // Even though the docu says passing null is invalid, this seems to help // activating the IME on the default input context that is shared with WPF threadMgr.SetFocus(IntPtr.Zero); } } }
public void UpdateCompositionWindow() { if (currentContext != IntPtr.Zero && textArea != null) { ImeNativeWrapper.SetCompositionWindow(hwndSource, currentContext, textArea); } }
void CreateContext() { if (this.textArea == null) { return; } //Dirkster99 BugFix if (this.textArea.Options == null) { return; } if (!textArea.Options.EnableImeSupport) { return; } hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); if (hwndSource != null) { currentContext = ImeNativeWrapper.GetContext(hwndSource); previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext); // ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea); hwndSource.AddHook(WndProc); } }
public void OnLostFocus(KeyboardFocusChangedEventArgs e) { if (e.OldFocus == textArea && currentContext != IntPtr.Zero) { ImeNativeWrapper.NotifyIme(currentContext); } ClearContext(); }
void ClearContext() { if (hwndSource != null) { //ImeNativeWrapper.AssociateContext(hwndSource, previousContext); //ImeNativeWrapper.ImmDestroyContext(currentContext); ImeNativeWrapper.ReleaseContext(hwndSource, currentContext); currentContext = IntPtr.Zero; hwndSource.RemoveHook(WndProc); hwndSource = null; } }
void ClearContext() { if (hwndSource != null) { ImeNativeWrapper.ImmAssociateContext(hwndSource.Handle, previousContext); ImeNativeWrapper.ImmReleaseContext(defaultImeWnd, currentContext); currentContext = IntPtr.Zero; defaultImeWnd = IntPtr.Zero; hwndSource.RemoveHook(WndProc); hwndSource = null; } }
void TextAreaLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (e.OriginalSource != this.textArea) { return; } if (currentContext != IntPtr.Zero) { ImeNativeWrapper.NotifyIme(currentContext); } ClearContext(); }