如何用API函数改变输入法? ( 积分: 100 )

  • 主题发起人 主题发起人 大唐电信
  • 开始时间 开始时间

大唐电信

Unregistered / Unconfirmed
GUEST, unregistred user!
我就想把一个窗口,比如一个TEdit的输入法改成智能全拼,我只想知道全部用API怎么实现,因为程序可能不是delphi写的,请各位高手赐教。<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢!!!!
 
我就想把一个窗口,比如一个TEdit的输入法改成智能全拼,我只想知道全部用API怎么实现,因为程序可能不是delphi写的,请各位高手赐教。<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢!!!!
 
参考<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=2004626<br>标题: 谁有关于输入法编程资料?百分相赠! (100分)<br><br>所有的函数都在这里了。看看哪个比较象<br>EnumInputContext<br>EnumRegisterWordProc<br>ImmAssociateContext<br>ImmAssociateContextEx<br>ImmConfigureIME<br>ImmCreateContext<br>ImmDestroyContext<br>ImmDisableIME<br>ImmEnumInputContext<br>ImmEnumRegisterWord<br>ImmEscape<br>ImmGetCandidateList<br>ImmGetCandidateListCount<br>ImmGetCandidateWindow<br>ImmGetCompositionFont<br>ImmGetCompositionString<br>ImmGetCompositionWindow<br>ImmGetContext<br>ImmGetConversionList<br>ImmGetConversionStatus<br>ImmGetDefaultIMEWnd<br>ImmGetDescription<br>ImmGetGuideLine<br>ImmGetIMEFileName<br>ImmGetImeMenuItems<br>ImmGetOpenStatus<br>ImmGetProperty<br>ImmGetRegisterWordStyle<br>ImmGetStatusWindowPos<br>ImmGetVirtualKey<br>ImmInstallIME<br>ImmIsIME<br>ImmIsUIMessage<br>ImmNotifyIME<br>ImmRegisterWord<br>ImmReleaseContext<br>ImmSetCandidateWindow<br>ImmSetCompositionFont<br>ImmSetCompositionString<br>ImmSetCompositionWindow<br>ImmSetConversionStatus<br>ImmSetOpenStatus Opens<br>ImmSetStatusWindowPos<br>ImmSimulateHotKey<br>ImmUnregisterWord <br>vc不用定义,bcb须#include &lt;imm.hpp&gt;<br>delphi须use imm
 
ActivateKeyboardLayout(Handle, KLF_ACTIVATE);<br>Handle是你想要要的输入法<br>在Delphi中可以这样获得<br>i : integer;<br>ImeName : string;<br>Handle : HWND;<br>i := Screen.Imes.IndexOf(ImeName);<br>if I &gt;= 0 then<br> &nbsp;Handle := HKL(Screen.Imes.Objects);<br>输入法名字可以直接从注册表中读的,位置是<br>HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Keyboard Layouts<br>中文输入法好像都是EXXXX804形式的
 
Screen.Imes.Objects这些是delphi的东东啊,,谁能给个纯API的例子。 &nbsp;请各位老大帮帮忙!!!!!!!!11
 
你可以用 ctrl 键一直找, 直到找到 api 为止。 看来楼主对delphi 不熟。 那就不要冒充打猎的了。
 
切换输入法<br>Uses ...,Shellapi <br>. <br>. <br>. <br>function MakeKeyboardLayout(PrimaryLanguage, SubLanguage: Integer): String; <br>begin <br> &nbsp;Result := IntToHex(PrimaryLanguage or (SubLanguage shl 10), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;KL_NAMELENGTH - 1); <br>end; <br><br>function FarsiKeyboardLayout: String; <br>begin <br> &nbsp;Result := MakeKeyboardLayout(LANG_FARSI,SUBLANG_DEFAULT); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>end; <br><br>function EnglishKeyboardLayout: String; <br>begin <br> &nbsp;Result := MakeKeyboardLayout(LANG_ENGLISH, SUBLANG_DEFAULT); <br>end; <br><br>procedure TForm1.FarsiKeyboard(Sender: TObject); <br>begin <br> &nbsp;if LoadKeyboardLayout(PChar(FarsiKeyboardLayout), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; KLF_ACTIVATE or KLF_REORDER) = 0 then <br> &nbsp; &nbsp;MessageDlg(ErrMsgFarsiKeyboard, mtError, [mbOK], 0); <br>end; <br><br>procedure TForm1.EnglishKeyboard(Sender: TObject); <br>begin <br> &nbsp;LoadKeyboardLayout(PChar(EnglishKeyboardLayout), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; KLF_ACTIVATE or KLF_REORDER); <br>end; <br><br>procedure TForm1.NextKeyboardActionExecute(Sender: TObject); <br>begin <br> &nbsp;ActivateKeyboardLayout(HKL_NEXT, 0);//在语言之间切换<br>end;
 
到这个地址<br>http://www.fm201.com<br>的 “下载中心” &nbsp; 看看,希望有帮助
 
我是看msdn上的资料写的,然后参加freepy的源码用delphi写了一个玩玩[:D]
 
后退
顶部