procedure HotKeyToShortCut(hotkey: Word; Modifier: UInt; var HKeyCtrl: TShortCut);
// convert HotKey value from shortcuts to Hotkey value compatible with TShortCut
var
Shift: TShiftState;
begin
Shift := [];
if (Modifier and MOD_SHIFT) <> 0 then
Shift := Shift + [ssShift];
if (Modifier and MOD_CONTROL) <> 0 then
Shift := Shift + [ssCtrl];
if (Modifier and MOD_ALT) <> 0 then
Shift := Shift + [ssAlt];
HKeyCtrl := ShortCut(HotKey, Shift);
end;
procedure ShortCutToHotKey(HKeyCtrl: TShortCut; var Key: Word; var Modifer: UInt);
// convert THotkey compatible Hotkey to shortcut hotkey.
var
Shift: TShiftState;
begin
ShortCutToKey(HKeyCtrl, Key, Shift);
Modifier := 0;
if (ssShift in Shift) then
Modifier := Modifier or MOD_SHIFT;
if (ssAlt in Shift) then
Modifier := Modifier or MOD_ALT;
if (ssCtrl in Shift) then
Modifier := Modifier or MOD_CONTROL;
end;
// example calls - translate to ShortCut
HotKeyToShortCut(keyComb, Modifier, HotKey1);
// translate ShortCut to HotKey
ShortCutToHotKey(HotKey1, keycomb, modifier);
// to show a ShortCut option in a caption
Label1.Caption := 'Press ' + ShortCutToText(t) + ' to trigger hotkey event.';