刷新输入法的问题(50分)

  • 主题发起人 主题发起人 gboyjuan
  • 开始时间 开始时间
G

gboyjuan

Unregistered / Unconfirmed
GUEST, unregistred user!
现在在做一个输入法控制的程序,但发现一个小问题:<br>通过调用Screen.Imes可以获取系统的所有输入法,但当程序正在运行的时候,增加后删除了系统输入法后,Screen.Imes仍然是未更新的,如何在程序不退出的情况去刷新Screen.Imes
 
下面是Screen.GetImes私有方法的代码,自己拷贝过去写一个函数自己用把。<br>function TScreen.GetImes: TStrings;<br>const<br> &nbsp;KbLayoutRegkeyFmt = 'System/CurrentControlSet/Control/Keyboard Layouts/%.8x'; &nbsp;// do not localize<br> &nbsp;KbLayoutRegSubkey = 'layout text'; // do not localize<br>var<br> &nbsp;TotalKbLayout, I, Bufsize: Integer;<br> &nbsp;KbList: array[0..63] of HKL;<br> &nbsp;qKey: HKey;<br> &nbsp;ImeFileName: array [Byte] of Char;<br> &nbsp;RegKey: array [0..63] of Char;<br>begin<br> &nbsp;if FImes = nil then<br> &nbsp;begin<br> &nbsp; &nbsp;FImes := TStringList.Create;<br><br> &nbsp; &nbsp;FDefaultIme := '';<br> &nbsp; &nbsp;TotalKbLayout := GetKeyboardLayoutList(64, KbList);<br><br> &nbsp; &nbsp;for I := 0 to TotalKbLayout - 1 do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;if Imm32IsIME(KbList) then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;if RegOpenKeyEx(HKEY_LOCAL_MACHINE,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StrFmt(RegKey, KbLayoutRegKeyFmt, [KbList]), 0, KEY_READ,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;qKey) = ERROR_SUCCESS then<br> &nbsp; &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Bufsize := sizeof(ImeFileName);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if RegQueryValueEx(qKey, KbLayoutRegSubKey, nil, nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @ImeFileName, @Bufsize) = ERROR_SUCCESS then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FImes.AddObject(ImeFileName, TObject(KbList));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if KbList = FDefaultKbLayout then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FDefaultIme := ImeFileName;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RegCloseKey(qKey);<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;TStringList(FImes).Duplicates := dupIgnore;<br> &nbsp; &nbsp;TStringList(FImes).Sorted := TRUE;<br> &nbsp;end;<br> &nbsp;Result := FImes;<br>end;
 
或者自己去改VCL也行。
 
我自己已经找到了解决办法,跟你说的一样,不过还是谢谢了
 
后退
顶部