...
private
{ Private-Deklarationen }
public
procedure Hotk(var m: TMessage); message wm_hotkey;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses Menus;
const
HKID: integer = 1;
procedure fehler(i: integer);
begin
showmessage('Fehler bei Registrierung von Hotkey ' + inttostr(i));
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Shift: TShiftState;
Key: Word;
begin
// ----- Strg+Alt+D ----------- dynamisch -------------------------------
if not registerhotkey(handle, HKID, MOD_ALT or MOD_CONTROL, ord('D'))
then fehler(HKID);
// -----------------------------------------------------------------------
inc(HKID);
// ----- Strg+V -------------- mit Komponente THotkey --------------------
ShortCutToKey(HotKey1.Hotkey, Key, Shift);
if not RegisterHotkey(handle, HKID,
ord(ssAlt in Shift) or ord(ssCtrl in Shift) * 2, Key)
then fehler(HKID);
// -----------------------------------------------------------------------
end;
procedure TForm1.FormDestroy(Sender: TObject);
var x: integer;
begin
for x := 1 to HKID do
UnRegisterHotkey(handle, x);
end;
procedure TForm1.Hotk(var m: TMessage);
begin
case m.wparam of
1: showmessage('D'); // z.B.
2: showmessage('V'); // z.B.
end;
end;