求助一段屏蔽 Alt +F4但是可以正常关闭的代码

10921092 2002-05-29 02:33:59
as title
...全文
108 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mudeen 2002-05-29
  • 打赏
  • 举报
回复
unit Unit1;

interface

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

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
HotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyId := GlobalAddAtom('HotKey') - $C000;
RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);

end;
procedure tform1.HotKeyDown(var Msg: Tmessage);
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;

end.
softwing 2002-05-29
  • 打赏
  • 举报
回复
向系统注册Alt+F4热键,然后在代码里什么也不做,这样可以屏蔽全局的 Alt+F4:
private
{ Private declarations }
HotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
// 什么也不做
end;
end;
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;
softwing 2002-05-29
  • 打赏
  • 举报
回复
向系统注册Alt+F4热键,然后在代码里什么也不做,这样可以屏蔽全局的 Alt+F4:
private
{ Private declarations }
HotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
// 什么也不做
end;
end;
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;
softwing 2002-05-29
  • 打赏
  • 举报
回复
向系统注册Alt+F4热键,然后在代码里什么也不做,这样可以屏蔽全局的 Alt+F4:
private
{ Private declarations }
HotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
// 什么也不做
end;
end;
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;
njbudong 2002-05-29
  • 打赏
  • 举报
回复
去掉:Alt+F4键
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
if (ssAlt in shift)and(key=115) then key:=0;
end;
正常关闭可以定义个全局变量来控制!
================================================================
一颗红心向前看,为了革命两茫然,不好意思才囊尽,只能说上一点点。
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
★ 我踢 我踢 我踢 我踢 我踢 我踢 我踢 我踢 我踢 ★
★ 你UP 你UP 你UP 你UP 你UP 你UP 你UP 你UP 你UP ★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
================================================================
Mudeen 2002-05-29
  • 打赏
  • 举报
回复
看过一段代码,向系统申请热键Alt+f4,然后放到程序中让它什么都不做。
shuyi 2002-05-29
  • 打赏
  • 举报
回复
设置一个窗体变量FInAlt
private
{ Private declarations }
FInAlt:boolean;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=18 then
FInAlt:=true
else if (key=115) and FInAlt then
key:=0;
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=18 then
FInAlt:=false;
end;

5,388

社区成员

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

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