[求助]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.
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!