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 @@ -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 @@ -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 @@ -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

Loading…
Cancel
Save