⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotkeyunit.pas

📁 热键管理控件源代码
💻 PAS
字号:
unit HotKeyUnit;

interface

uses
  Classes;

procedure InitDll;


implementation

uses
  SysUtils, HotKeyManager, Windows, Dialogs;

type
  TContainer = class    // A dummy class that allows us to use event methods
    hkm: THotKeyManager;
    procedure HotKeyPressed(HotKey: Cardinal; Index: Word);
  end;

var
  Container: TContainer;

procedure TContainer.HotKeyPressed(HotKey: Cardinal; Index: Word);
begin
  ShowMessage(HotKeyToText(HotKey, True) + ' pressed.');
end;

procedure InitDll;
var
  HotKey: Cardinal;
  HotKeyIndex: Word;
begin
  Container := TContainer.Create;
  Container.hkm := THotKeyManager.Create(nil);
  Container.hkm.OnHotKeyPressed := Container.HotKeyPressed;
  HotKey := GetHotKey(MOD_ALT, VK_HOME);
  if HotKey = 0 then
    ShowMessage('Invalid hotkey.');
  HotKeyIndex := Container.hkm.AddHotKey(HotKey);
  if HotKeyIndex = 0 then
    ShowMessage('Could not register hotkey.');
end;


initialization

finalization
  if Container <> nil then
  begin
    Container.hkm.Free;
    Container.Free;
  end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -