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

📄 hotkey.pas

📁 支持库类 / 模块控件 / 支持库类 eLIB++支持库 源代码 Delphi
💻 PAS
字号:
unit HotKey;


interface
uses elibTypes,windows,SysUtils;

procedure RegHotKey(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
procedure UnRegHotKey(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;

implementation

procedure RegHotKey(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
var
  wnd:HWND;
  id:integer;
  modifier:Cardinal;
  vk:Cardinal;
  idStr:string;
  idAdd:integer;
begin
  pRetData.m_Value.m_int:=0;
  wnd:=ArgArray(pArgInf)[0].m_Value.m_int;
  modifier:=ArgArray(pArgInf)[1].m_Value.m_int;
  vk:=ArgArray(pArgInf)[2].m_Value.m_int;
  //Get the only id for this hotkey
  idStr:='eLib++HotKey';
  idAdd:=0;
  id:=0;
  while (GlobalFindAtom(PChar(idStr))<>0) and (idAdd<=9999) do
  begin
    idStr:='eLib++HotKey'+inttostr(idAdd);
    inc(idAdd);
  end;//while
  id:=GlobalAddAtom(PChar(idStr));
  if id=0 then exit;
  {$IFDEF __DEBUG}
  MessageBox(0,PChar(inttostr(id)),PChar(idStr),mb_ok);
  {$ELSE}
  {$ENDIF}
  id:=id-$C000;
  if RegisterHotKey(wnd,id,modifier,vk)then pRetData.m_Value.m_int:=id;
end;//procedure RegHotKey

 procedure UnRegHotKey(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
 var
  wnd:integer;
  id:integer;
  r:LongBool;
 begin
  wnd:=ArgArray(pArgInf)[0].m_Value.m_int;
  id:=ArgArray(pArgInf)[1].m_Value.m_int;
  if GlobalDeleteAtom(id+$C000)=0 then r:=true else r:=false;
  r:=r and UnregisterHotKey(wnd,id);
  pRetData.m_Value.m_BOOL:=r;
 end;//procedure UnRegHotKey

end.

⌨️ 快捷键说明

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