先設置form1.keypreview := TRUE:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Shift <> [] then Exit;
case Key of
VK_F2:
if BtnAdd.CanFocus then
begin
BtnAdd.SetFocus;
BtnAddClick(nil);
end; VK_F3:
if BtnDel.CanFocus then
begin
BtnDel.SetFocus;
BtnDelClick(nil);
end;
end;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Shift <> [] then Exit;
case Key of
VK_F2:
if BtnAdd.CanFocus then
begin
BtnAdd.SetFocus;
BtnAddClick(nil);
end; VK_F3:
if BtnDel.CanFocus then
begin
BtnDel.SetFocus;
BtnDelClick(nil);
end;
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货