unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure myshortcut(var message: Tmessage); message WM_HOTKEY;
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
id:integer;
implementation
{$R *.dfm}
procedure TForm1.myshortcut(var message:TMessage);
begin
showMessage('你好,你按下了Ctrl+F11键!');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
id:=GlobalAddAtom('hotkey2');
RegisterHotKey(handle,id,mod_control,vk_F11);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,id); //别忘了在退出时取消定义
end;
end.