首页
社区
课程
招聘
[求助]delphi如用在dll中注册热键
发表于: 2018-9-11 08:56 4610

[求助]delphi如用在dll中注册热键

2018-9-11 08:56
4610

在窗口中可以,但不知在dll如何弄?
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
{ Private declarations }
//定义全局变量
CTRL_A: INTEGER;
//热键响应函数
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;

 

public
{ Public declarations }
end;

 

var
Form1: TForm1;

 

implementation

 

{$R *.dfm}
procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
//CTRL+A
if (Msg.LparamLo = MOD_CONTROL) AND (Msg.LParamHi = 65) then //退出
begin
ShowMessage('按了CTRL+A');
end;

 

end;

 

procedure TForm1.FormCreate(Sender: TObject);
begin
CTRL_A:=GlobalAddAtom('MyCTRL_A') - $C000;
RegisterHotKey(Handle, CTRL_A, MOD_CONTROL, 65);
end;

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//释放热键
UnRegisterHotKey(handle, CTRL_A);
end;

 

end.


[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 62
活跃值: (2052)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2

正常窗口中运行如图

上传的附件:
2018-9-11 09:06
0
游客
登录 | 注册 方可回帖
返回
//