From 2aa2ddb4569dd8d9eef2171a68e41b71e99be27f Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 12 Oct 2012 17:16:13 +0200 Subject: [PATCH] Create a new IME context instead of using the default one. --- .../ICSharpCode.AvalonEdit/Editing/ImeSupport.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs index abf075981a..4e6dc51af0 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs @@ -23,6 +23,7 @@ namespace ICSharpCode.AvalonEdit.Editing { readonly TextArea textArea; IntPtr currentContext; + IntPtr previousContext; HwndSource hwndSource; public ImeSupport(TextArea textArea) @@ -45,7 +46,8 @@ namespace ICSharpCode.AvalonEdit.Editing void ClearContext() { if (hwndSource != null) { - ImeNativeWrapper.ReleaseContext(hwndSource, currentContext); + ImeNativeWrapper.AssociateContext(hwndSource, previousContext); + ImeNativeWrapper.ImmDestroyContext(currentContext); currentContext = IntPtr.Zero; hwndSource.RemoveHook(WndProc); hwndSource = null; @@ -64,7 +66,8 @@ namespace ICSharpCode.AvalonEdit.Editing return; hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); if (hwndSource != null) { - currentContext = ImeNativeWrapper.GetContext(hwndSource); + currentContext = ImeNativeWrapper.ImmCreateContext(); + previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext); // ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea); hwndSource.AddHook(WndProc); // UpdateCompositionWindow() will be called by the caret becoming visible