用
SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @Dummy, 0);
不能屏蔽Alt + F4,只能屏蔽其它一些系统功能键。
谢谢!
5 个解决方案
#1
procedure TForm1.Button1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=VK_F4) and(Shift=[ssAlt]) then
begin
KEY:=0;
Shift:=[];
end;
end;
Shift: TShiftState);
begin
if (key=VK_F4) and(Shift=[ssAlt]) then
begin
KEY:=0;
Shift:=[];
end;
end;
#2
其实要屏蔽别人退出程序的方法可以用以下action的开关来实现
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
#3
or
FormCloseQuery()
FormCloseQuery()
#4
同意zxh1972的方法,很好!
#5
只要将 TForm 的 KeyPreview 设为 True;然后:
procedure TForm1.form1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=115 then
KEY:=0;
end;
即可
procedure TForm1.form1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=115 then
KEY:=0;
end;
即可
#1
procedure TForm1.Button1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=VK_F4) and(Shift=[ssAlt]) then
begin
KEY:=0;
Shift:=[];
end;
end;
Shift: TShiftState);
begin
if (key=VK_F4) and(Shift=[ssAlt]) then
begin
KEY:=0;
Shift:=[];
end;
end;
#2
其实要屏蔽别人退出程序的方法可以用以下action的开关来实现
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
#3
or
FormCloseQuery()
FormCloseQuery()
#4
同意zxh1972的方法,很好!
#5
只要将 TForm 的 KeyPreview 设为 True;然后:
procedure TForm1.form1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=115 then
KEY:=0;
end;
即可
procedure TForm1.form1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=115 then
KEY:=0;
end;
即可