允許TextBox輸入中文(IME On,默認狀態)
<TextBox Width="200" InputMethod.PreferredImeState="On"
InputMethod.IsInputMethodEnabled="True"
InputMethod.PreferredImeConversionMode="FullShape,Native"></TextBox>
禁止TextBox輸入中文(IME Off)
<TextBox Width="200" InputMethod.PreferredImeState="Off"
InputMethod.IsInputMethodEnabled="False"></TextBox>
指定默認輸入法爲中文(IME On)
<TextBox Width="200" InputLanguageManager.InputLanguage="zh-CN"></TextBox>
枚舉輸入法
foreach (System.Windows.Forms.InputLanguage lang in System.Windows.Forms.InputLanguage.InstalledInputLanguages)
if (lang.LayoutName == "Japanese")
{
System.Windows.Forms.InputLanguage.CurrentInputLanguage = lang;
InputMethod.Current.ImeState = InputMethodState.On;
}
檢查物理鍵盤是否存在
KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
return keyboardCapabilities.KeyboardPresent != 0 ? true : false;
windows自帶的虛擬鍵盤
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");
WPF TextBox PreviewTextInput handle IME (chinese)
http://blog.csdn.net/muzizongheng/article/details/9291637
TextBox控件,模擬鍵盤輸入(經過IME,所以目標能通過發送英文字符收到中文字符)
1 2 3 |
|
TextBox控件,模擬鍵盤輸入(不經過IME,所以目標不能通過發送英文字符收到中文字符)
1 2 3 4 5 6 7 8 9 10 11 |
|
打開IME的一種方式
Window mainWindow = Application.Current.MainWindow;
WindowInteropHelper helper = new WindowInteropHelper(mainWindow);
IntPtr hImc = ImmGetContext(helper.Handle);
bool imeOpen = ImmGetOpenStatus(hImc);
如何控制IME的composition window位置
http://bbs.csdn.net/topics/340034551