谁能告诉我一个屏蔽'alt+f4'的方法?

hzzkf 2000-03-03 02:57:00
谁能告诉我一个屏蔽'alt+f4'的方法?(delphi),谢谢!
hzzkf@sina.com
...全文
358 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
supershan 2000-03-05
  • 打赏
  • 举报
回复
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssAlt in shift) and (Key=VK_F4) then
begin
B:=False;
FormCloseQuery(sender,B);
end;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if B=False then
CanClose:=False
else
CanClose:=True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
B:=True;
Close;
end;
jwchc 2000-03-05
  • 打赏
  • 举报
回复
agui说得对。
TeamD 2000-03-04
  • 打赏
  • 举报
回复
同意 AcherMagic 的意见。
tide 2000-03-04
  • 打赏
  • 举报
回复
如果想屏蔽系统所有'alt+f4',可以通过修改注册表完成。


5201314 2000-03-03
  • 打赏
  • 举报
回复
很简单,在form的onclosequery中加入canclose:=false;(最好还有个判断)
jilimi 2000-03-03
  • 打赏
  • 举报
回复
一个很简单的方法:在此窗体中增加一个PopMenu,再随便增加一个菜单项,使其不可见,设置其热键为Alt+F4,事件代码则为什么都不做,即可!

AcherMagic 2000-03-03
  • 打赏
  • 举报
回复
在FORM的private中声明一变量
AClose : Boolean;

FormCreate时
AClose := False;

关闭窗口的button Click时
AClose := True;

在Form的OnCloseQuery中检测
AClose的值

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
canclose := False;
if AClose then
begin
canclose := True;
end;
end;
这样做虽然笨一点,但也能达到需要的效果。
hubdog 2000-03-03
  • 打赏
  • 举报
回复
对了忘了说了,如果你不是动态释放form,你在form.oncreate里最好设定
self.onclosequery:=FormCloseQuery;
hubdog 2000-03-03
  • 打赏
  • 举报
回复
easy,处理form.onclosequery就可以了
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }

end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
canclose:=false;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
self.OnCloseQuery:=nil;
close;
end;

end.
//给分吧:)
Lin 2000-03-03
  • 打赏
  • 举报
回复
没那么复杂:在Form的OnClose事件中设置变量Action := caNone即可.
sess 2000-03-03
  • 打赏
  • 举报
回复
如果想屏蔽系统所有'alt+f4',而不是仅仅所设计的程序,只有进行键值捕获
光明山人 2000-03-03
  • 打赏
  • 举报
回复
var
hSysMenu: HMENU;

hSysMenu := GetSystemMenu( Form.Handle, FALSE );
EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED );

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧