调用输入法。(50分)

  • 主题发起人 主题发起人 少爷的拐杖
  • 开始时间 开始时间

少爷的拐杖

Unregistered / Unconfirmed
GUEST, unregistred user!
一个没有imename属性的输入控件。<br>一个已知的输入法名称。从Screen.Imes里得来的。<br>怎么能在输入控件获得焦点的时候调用这个输入法呢?<br><br>我曾经拥有这样的代码,可惜找不到了。<br>如果上天再给我一次机会。我会好好保留以前的代码的。。。。
 
给你两个函数.SetmyIme用于设置,ResetIme用于恢复.<br><br>procedure SetmyIme(ImeName:string);<br>var<br>&nbsp; I: Integer;<br>&nbsp; HandleToSet: HKL;<br>begin<br>&nbsp; if not SysLocale.FarEast then Exit;<br>&nbsp; if ImeName &lt;&gt; '' then<br>&nbsp; begin<br>&nbsp; &nbsp; if (AnsiCompareText(ImeName, Screen.DefaultIme) &lt;&gt; 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; and (Screen.Imes.Count &lt;&gt; 0) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; HandleToSet := Screen.DefaultKbLayout;<br>&nbsp; &nbsp; &nbsp; I := Screen.Imes.IndexOf(ImeName);<br>&nbsp; &nbsp; &nbsp; if I &gt;= 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; HandleToSet := HKL(Screen.Imes.Objects);<br>&nbsp; &nbsp; &nbsp; ActivateKeyboardLayout(HandleToSet, KLF_ACTIVATE);<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure ResetmyIme(ImeName:string);<br>begin<br>&nbsp; if not SysLocale.FarEast then Exit;<br>&nbsp; if ImeName &lt;&gt; '' then<br>&nbsp; begin<br>&nbsp; &nbsp; if AnsiCompareText(ImeName, Screen.DefaultIme) &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp; ActivateKeyboardLayout(Screen.DefaultKbLayout, KLF_ACTIVATE);<br>&nbsp; end;<br>end;<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; SetmyIme('输入法');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; ResetmyIme('输入法');<br>end;<br><br>我找到了。
 
我试试先。。。。
 
接受答案了.
 
后退
顶部