Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.';
var
keycomb: Word; // key press.
Modifier: UINT; // modifier such as any combination of Shift, Alt, Ctrl.
ExecuteHotKey: Integer; // key value or message.
// register
ExecuteHotKey := GlobalAddAtom('ExecuteHotKey');
RegisterHotKey(Handle, ExecuteHotKey, Modifier, keycomb);
// unregister
UnRegisterHotKey(Handle, ExecuteHotKey);
GlobalDeleteAtom(ExecuteHotKey);
TForm1 = class(TForm)
...
private
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if (msg.HotKey = ExecuteHotKey) then
begin
// do hotkey related things.
end;
end;