procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key=VK_ESCAPE then self.close; //form1的keypreview要设为true end;
根据ESC的键值,是27吧,你看一下, 然后在窗体的keydown事件中 if key=27 then close;
procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key=27 then close; end; 记得,一定要把 frmMain的keypreview设置成为True;默认为false
Shift: TShiftState);
begin
if key=VK_ESCAPE then self.close; //form1的keypreview要设为true
end;
然后在窗体的keydown事件中
if key=27 then
close;
Shift: TShiftState);
begin
if key=27 then close;
end;
记得,一定要把 frmMain的keypreview设置成为True;默认为false