请问如何屏蔽Alt+F4键???急急急!!!(10分)

A

attar

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何屏蔽Alt+F4键???急急急!!!
我用以下方法屏蔽了三键Alt+Ctrl+Del等系统键
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1,0, 0);
并用如下方法屏蔽了Alt+F4
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
if (ssAlt in shift)and(key=115) then key:=0;
end;
但是把这两个放在一起就不能屏蔽Alt+F4了,是不是有冲突?能解决么?
急急急!!!
 
你可以把ALT+F4注册成自己程序的热键。
 
如何做呢?
小弟是个菜鸟,还望多指点!!!
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }

procedure HotKeyDown(var Msg: Tmessage);
message WM_HOTKEY;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
HotKeyId: Integer;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyId := GlobalAddAtom('HotKey') - $C000;
RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotKey(handle, HotKeyId);
end;

procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
SHOWMESSAGE('AA');//DO YOURTHINGS
end;
END;
END.
 
tform.onclose函数的有个boolean参数,在该函数处理里,将该boolean:=false;
 
非常感谢!
这是一个方法,那还有没有别的呢?有没有直接屏蔽的!能不能说详细些?
to kingdeezj:
我回头给你加分!!!真的!!!谢谢你!!!
这是一个间接的方法吧,还有没有别的?
 
[:D]
编写一段代码,这部份代码写在应用程序的dpr文件中,如下:
program yygl;

uses
Forms,
wsmain in 'wsmain.pas' {FMyygl},
icxtdr in 'icxtdr.pas' {Fmxtdr},
xtcz in 'xtcz.pas' {Fmxtcz};

{$R *.RES}

begin
 //系统登录窗口
 Fmxtdr := TFmxtdr.Create(application);
Fmxtdr.showmodal;
if Fmxtdr.ModalResult = 1 then
begin
Application.Initialize;
Application.CreateForm(TFMyygl, FMyygl);
Application.CreateForm(TFmxtdr, Fmxtdr);
Application.CreateForm(TFmxtcz, Fmxtcz);
Application.Run;
end;
end.

在系统登录窗口关闭时,写上modalresult:=mrok;即可
 
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
canclose:=false;
end;
 
在Form的Close事件处理中,将Action:=caNone即可。注意,它是一个变量参数[:)]
 
多人接受答案了。
 
顶部