zoukankan      html  css  js  c++  java
  • 20111228_给窗体设置默认输入法

    //给窗体设置默认输入法

    //新建一个窗体类ImeForm,设置Form1:ImeForm

    public class ImeForm:System.Windows.Forms.Form
    {
    [DllImport("imm32.dll")]
    public static extern IntPtr ImmGetContext(IntPtr hWnd);
    [DllImport("imm32.dll")]
    public static extern bool ImmGetConversionStatus(IntPtr hIMC,ref int conversion, ref int sentence);
    [DllImport("imm32.dll")]
    public static extern bool ImmSetConversionStatus(IntPtr hIMC, int conversion, int sentence);

    //重载Form的OnActivated
    protected override void OnActivated(EventArgs e)
    {
    foreach (InputLanguage iL in InputLanguage.InstalledInputLanguages)
    {
    if (iL.LayoutName.Contains("搜狗拼音输入法"))
    {
    InputLanguage.CurrentInputLanguage = iL;
    break;
    }
    if (iL.LayoutName.Contains("智能 ABC"))
    {
    InputLanguage.CurrentInputLanguage = iL;
    break;
    }
    }
    IntPtr prt = ImmGetContext(this.Handle);
    int iMode = 1;
    int iSentence = 0;
    if (!ImmSetConversionStatus(prt, iMode, iSentence))
    {
    //MessageBox.Show("change error");
    }
    }
    }

    还有设置半角输入法:

    this.ImeMode = ImeMode.OnHalf;  //写在Page_load中

  • 相关阅读:
    Redis集群(一)
    Mysql分库分表
    Redisson分布式锁
    Spring Cloud Eureka 高可用
    Spring RestTemplate具备负载均衡功能
    Redis分布式锁
    B树/B-树/B+树/B*树的数据库应用
    ABAC访问控制模型
    Maven自定义打包的包名
    Versions maven plugin 修改版本
  • 原文地址:https://www.cnblogs.com/kimblog/p/2304188.html
Copyright © 2011-2022 走看看