来源:www.cncfan.com | 2006-1-17 | (有2771人读过)
unit hotkey;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure OnHotKey(var Message :TWMHotKey); Message WM_HotKey; procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; hotkey1: integer;//这里用hotkey:integer会出错!
implementation
{$R *.DFM} procedure TForm1.OnHotKey(var Message :TWMHotKey); begin ///////////// To shaofun 你可以在这里做快捷键检测 /// if …… ShowMessage('热键捕获成功'); end;
procedure TForm1.FormCreate(Sender: TObject); begin HotKey1:=GlobalAddAtom('Vinsa'); RegisterHotKey(handle,HotKey1,MOD_ALT or MOD_CONTROL,88); //热键是Ctrl+Alt+X; end;
procedure TForm1.FormDestroy(Sender: TObject); begin UnRegisterHotKey(handle,HotKey1); end;
end.
|