在KeyPress中写如下代码:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
s: array[0..255] of char;
begin
GetKeyboardLayoutName(s);
if s <> '00000804' then
Key := #0;
end;
注:我机器上英文输入法是00000804,基本上机器都是这样。如果需要确认,可以在注册表中
Local_MACHINE\SYSTEM\CurrentControlSet\Keyboard Layouts中查找。
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
s: array[0..255] of char;
begin
GetKeyboardLayoutName(s);
if s <> '00000804' then
Key := #0;
end;
注:我机器上英文输入法是00000804,基本上机器都是这样。如果需要确认,可以在注册表中
Local_MACHINE\SYSTEM\CurrentControlSet\Keyboard Layouts中查找。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货