Ich wollte mir 4 Hotkeys registieren.
Nur dummerweise scheint es nicht zu gehen...
Delphi-Quellcode:
procedure TfrmMain.Settings1Click(Sender: TObject);
var
sc : TShortcutArray;
i : Integer;
Modifiers : Uint;
Key : Word;
begin
sc := frmSettings.ShowModal;
for i := 1
to High(sc)
do begin
ShortCutToHotKey(sc[i], Key, Modifiers);
hotkeyIDs[i] := GlobalAddAtom(PChar('
hk' + IntToStr(i)));
if not RegisterHotKey(
Handle, hotkeyIDs[i], Modifiers, Key)
then
Showmessage('
Can''
t register hotkey ' + ShortCutToText(sc[i]) + '
.');
end;
end;
procedure ShortCutToHotKey(HotKey: TShortCut;
var Key : Word;
var Modifiers: Uint);
var
Shift: TShiftState;
begin
ShortCutToKey(HotKey, Key, Shift);
Modifiers := 0;
if (ssShift
in Shift)
then
Modifiers := Modifiers
or MOD_SHIFT;
if (ssAlt
in Shift)
then
Modifiers := Modifiers
or MOD_ALT;
if (ssCtrl
in Shift)
then
Modifiers := Modifiers
or MOD_CONTROL;
end;
Die Hotkey sind:
<strg> + <o>
<strg> + <s>
<strg> + <alt> + <r>
<strg> + <alt> + <c>