SIL.Windows.Forms.Keyboarding/Windows/WinKeyboardAdaptor.cs
/// <summary>
/// Restore the conversion and sentence mode to the states they had last time
/// we activated this keyboard (unless we never activated this keyboard since the app
/// got started, in which case we use sensible default values).
/// </summary>
Restore the conversion and sentence mode to the states they had last time
we activated this keyboard (unless we never activated this keyboard since the app
got started, in which case we use sensible default values).
Restore the conversion and sentence mode to the states they had last time we activated this keyboard ( unless we never activated this keyboard since the app got started in which case we use sensible default values ) .
private void RestoreImeConversionStatus(IKeyboardDefinition keyboard)
		{
			var winKeyboard = keyboard as WinKeyboardDescription;
			if (winKeyboard == null)
				return;
			var windowPtr = winKeyboard.WindowHandle != IntPtr.Zero ? winKeyboard.WindowHandle : Win32.GetFocus();
			var windowHandle = new HandleRef(this, windowPtr);
			var contextPtr = Win32.ImmGetContext(windowHandle);
			if (contextPtr == IntPtr.Zero)
				return;
			var contextHandle = new HandleRef(this, contextPtr);
			Win32.ImmSetConversionStatus(contextHandle, winKeyboard.ConversionMode, winKeyboard.SentenceMode);
			Win32.ImmReleaseContext(windowHandle, contextHandle);
			winKeyboard.WindowHandle = windowPtr;
		}
private void RestoreImeConversionStatus ( IKeyboardDefinition keyboard ) { var winKeyboard = keyboard as WinKeyboardDescription ; if ( winKeyboard == null ) return ; var windowPtr = winKeyboard . WindowHandle != IntPtr . Zero ? winKeyboard . WindowHandle : Win32 . GetFocus ( ) ; var windowHandle = new HandleRef ( this , windowPtr ) ; var contextPtr = Win32 . ImmGetContext ( windowHandle ) ; if ( contextPtr == IntPtr . Zero ) return ; var contextHandle = new HandleRef ( this , contextPtr ) ; Win32 . ImmSetConversionStatus ( contextHandle , winKeyboard . ConversionMode , winKeyboard . SentenceMode ) ; Win32 . ImmReleaseContext ( windowHandle , contextHandle ) ; winKeyboard . WindowHandle = windowPtr ; }
Restore the conversion and sentence mode to the states they had last time
we activated this keyboard (unless we never activated this keyboard since the app
got started, in which case we use sensible default values).
Restore the conversion and sentence mode to the states they had last time we activated this keyboard ( unless we never activated this keyboard since the app got started in which case we use sensible default values ) .
// Restore the state of the new keyboard to the previous value. If we don't do // that e.g. in Chinese IME the input mode will toggle between English and // Chinese (LT-7487 et al). // NOTE: Windows uses the same context for all windows of the current thread, so it // doesn't really matter which window handle we pass. // NOTE: Chinese Pinyin IME allows to switch between Chinese and Western punctuation. // This can be selected in both Native and Alphanumeric conversion mode. However, // when setting the value the punctuation setting doesn't get restored in Alphanumeric // conversion mode, not matter what I try. I guess that is because Chinese punctuation // doesn't really make sense with Latin characters.
keyboard
IKeyboardDefinition