
13.04.2015, 06:08
|
Прохожий
|
|
Регистрация: 25.11.2011
Сообщения: 26
Репутация: 10
|
|
Вот исходник, что не так делаю?
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
HotKey1: THotKey;
HotKey2: THotKey;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
hk_1, hk_2: Integer;
procedure WMHotKey(var Mess:TWMHotKey);message WM_HOTKEY;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMHotKey(var Mess: TWMHotKey);
begin
if mess.HotKey=hk_1 then showmessage('Комбинация клавиш 1');
if mess.HotKey=hk_2 then showmessage('Комбинация клавиш 2');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
hk_1:=GlobalAddAtom('Hotkey1');
RegisterHotKey(Handle, hk_1 , 0, HotKey1.HotKey);
hk_2:=GlobalAddAtom('Hotkey2');
RegisterHotKey(Handle, hk_2 , 0, HotKey2.HotKey);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, hk_1);
GlobalDeleteAtom(hk_1);
UnRegisterHotKey(Handle, hk_2);
GlobalDeleteAtom(hk_2);
end;
end.
|