WinForm在做輸入法切換時常發生錯誤。
Google了一下
寫個FormBase讓視窗繼承:
#region 解決輸入法BUG
//解決輸入法BUG
[DllImport("imm32.dll")]
public static extern IntPtr ImmGetContext(IntPtr hwnd);
[DllImport("imm32.dll")]
public static extern bool ImmSetOpenStatus(IntPtr himc, bool b);
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
IntPtr HIme = ImmGetContext(this.Handle);
ImmSetOpenStatus(HIme, true);
}
#endregion
private void InitializeComponent()
{
//停用IMEMODE
this.ImeMode = System.Windows.Forms.ImeMode.Off;
}
沒有留言:
張貼留言