程序员只需要将窗体中该输入中文的控件的 imemode=imchinese,然后在每个窗体里 create(或active) 事件里调用本人编写的方法changeyouformallcontrolime(frm)即可.在程序中提供一个用户输入法选项供用户选择自己喜欢的输入法,调用显示frmimenamelist 窗体即可!总之,程序员只需要调用 一个公用 unit(含有窗体的unit) 下的方法: changeyouformallcontrolime(yformname:twincontrol), 调用显示窗体 frmimenamelist
实现方法: unit 名字 unitimemanager 包含的窗体名字 frmimenamelist
界面操作的代码:

procedure tfrmimenamelist.formcreate(sender: tobject); //列表框加载系统输入法
begin
listbox1.items:=screen.imes;
end;
procedure tfrmimenamelist.bitbtn1click(sender: tobject);//保存用户选择的输入法存放到系统注册表里面
var
reg:tregistry;
custimename:string;
begin
reg:=tregistry.create;
reg.rootkey:=hkey_local_machine;
if listbox1.itemindex<>-1 then
custimename:=listbox1.items[listbox1.itemindex]
else
custimename:='中文 (简体) - 智能 abc';
try
if reg.openkey('\software\imecustom', true) then reg.writestring('customimename',custimename);
finally
reg.closekey;
reg.free;
end;
frmimenamelist.close;
end;
原代码实现的思路: 。
提供一个列举系统所有输入法的窗体,供用户选择,将选择的中文输入法保存到系统注册表里。 .
提供一个方法 ChangeYouFormAllControlIme(form) ,form 是需要输入的窗体名称,枚举出相应窗体具有输入法的控件。 特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系.
提供一个方法 JugeClassType(PClass:Tcontrol),判断每一个控件的实际类型,根据其ImeMode(为了程序设计简便,当值 为imchinese 时,切换为用户选择的中文输入法 ,其它切换为英文) .
下面是主要原代码: ...
//判断控件类型切换中英文这个只能具体判断,无法用 Twincontrol 笼统判别或概括 .

procedure JugeClassType(PClass:Tcontrol;
begin
if pclass is TEdit then
begin
if TEdit(pclass).ImeMode=imchinese then
TEdit(pclass).ImeName:=StrImeName (StrImeName 注册表保存的中文输入法名)同)
else
TEdit(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TMemo then
begin
if TMemo(pclass).ImeMode=imchinese then
TMemo(pclass).ImeName:=StrImeName
else
TMemo(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TComboBox then
begin
if TComboBox(pclass).ImeMode=imchinese then
TComboBox(pclass).ImeName:=StrImeName
else
TComboBox(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TRichEdit then
begin
if TRichEdit(pclass).ImeMode=imchinese then
TRichEdit(pclass).ImeName:=StrImeName
else
TRichEdit(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TDBGrid then
begin
if TDBGrid(pclass).ImeMode=imchinese then
TDBGrid(pclass).ImeName:=StrImeName
else
TDBGrid(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TDBEdit then
begin
if TDBEdit(pclass).ImeMode=imchinese then
TDBEdit(pclass).ImeName:=StrImeName
else
TDBEdit(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TDbMemo then
begin
if TDbMemo(pclass).ImeMode=imchinese then
TDbMemo(pclass).ImeName:=StrImeName
else
TDbMemo(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TDbcombobox then
begin
if TDbcombobox(pclass).ImeMode=imchinese then
TDbcombobox(pclass).ImeName:=StrImeName
else
TDbcombobox(pclass).ImeMode:=imClose;
exit;
end;
if pclass is Tdblookupcombobox then
begin
if Tdblookupcombobox(pclass).ImeMode=imchinese then
Tdblookupcombobox(pclass).ImeName:=StrImeName
else
Tdblookupcombobox(pclass).ImeMode:=imClose;
exit;
end;
if pclass is Tdbrichedit then
begin
if Tdbrichedit(pclass).ImeMode=imchinese then
Tdbrichedit(pclass).ImeName:=StrImeName
else
Tdbrichedit(pclass).ImeMode:=imClose;
exit;
end;
if pclass is TMaskEdit then
begin
if TMaskEdit(pclass).ImeMode=imchinese then
TMaskEdit(pclass).ImeName:=StrImeName
else
TMaskEdit(pclass).ImeMode:=imClose;
exit;
end;
end;
功的人生,需要自己去经营,别再说了,莫再等了,现在就为自己的人生做好规划,为人生点亮一盏明灯,赢在人生起跑点上。
//这个方法,您只需要在需要切换中英文的窗体 oncreate 事件里调用就可以了。YFormName,需要切换中英文的窗体。 ...

Procedure ChangeYouFormAllControlIme(YFormName:TWinControl);
var
i:integer;
ChildControl:TControl;
Reg:TRegistry;
YouFormOrOTher:Twincontrol;
begin
YouFormOrOTher:=YFormName;
reg:=TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
try
if Reg.OpenKey(''''''''\Software\IMeCustom'''''''',false)=true then
StrImeName:=reg.ReadString(''''''''CustomIMeName'''''''');
finally
reg.CloseKey;
reg.Free;
end;
for i:=0 to YouFormOrOTher.ControlCount-1 do
begin
ChildControl:=YouFormOrOTher.Controls[i];
JugeClassType(ChildControl);
if ChildControl is TWinControl then ChangeYouFormAllControlIme(ChildControl as TWinControl);
end;
end;
end.
枚举输入法,并将用户的选择保存到注册表里,很简单,这个大家可以自己实现。例如 根据专家观察,这样的理论和现象都是值得各位站长深思的,所以希望大家多做研究学习,争取总结出更多更好的经验!
ListBox1.Items:=screen.Imes;