Browse Source

Create a new IME context instead of using the default one.

pull/28/head
Daniel Grunwald 13 years ago
parent
commit
2aa2ddb456
  1. 7
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs

7
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs

@ -23,6 +23,7 @@ namespace ICSharpCode.AvalonEdit.Editing
{ {
readonly TextArea textArea; readonly TextArea textArea;
IntPtr currentContext; IntPtr currentContext;
IntPtr previousContext;
HwndSource hwndSource; HwndSource hwndSource;
public ImeSupport(TextArea textArea) public ImeSupport(TextArea textArea)
@ -45,7 +46,8 @@ namespace ICSharpCode.AvalonEdit.Editing
void ClearContext() void ClearContext()
{ {
if (hwndSource != null) { if (hwndSource != null) {
ImeNativeWrapper.ReleaseContext(hwndSource, currentContext); ImeNativeWrapper.AssociateContext(hwndSource, previousContext);
ImeNativeWrapper.ImmDestroyContext(currentContext);
currentContext = IntPtr.Zero; currentContext = IntPtr.Zero;
hwndSource.RemoveHook(WndProc); hwndSource.RemoveHook(WndProc);
hwndSource = null; hwndSource = null;
@ -64,7 +66,8 @@ namespace ICSharpCode.AvalonEdit.Editing
return; return;
hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea);
if (hwndSource != null) { if (hwndSource != null) {
currentContext = ImeNativeWrapper.GetContext(hwndSource); currentContext = ImeNativeWrapper.ImmCreateContext();
previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext);
// ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea); // ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea);
hwndSource.AddHook(WndProc); hwndSource.AddHook(WndProc);
// UpdateCompositionWindow() will be called by the caret becoming visible // UpdateCompositionWindow() will be called by the caret becoming visible

Loading…
Cancel
Save