Delphi 搭配HotKeyEdit控件来解决问题

2022-12-28 16:28:05 作者:admin

本文整理自网络,侵删。

 function ShiftStateToWord(Shift: TShiftState): Word; //热键组合键分解   private     { Private declarations }     var       aatom: ATOM;       Key, Shift: Word;   public     { Public declarations }     procedure hotkey(var msg: TMessage); message WM_HOTKEY;//定义全局热键消息事件function TForm1.ShiftStateToWord(Shift: TShiftState): Word;begin  if ssShift in Shift then    Result := MOD_SHIFT;  if ssCtrl in Shift then    Result := Result or MOD_CONTROL;  if ssAlt in Shift then    Result := Result or MOD_ALT;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin  UnregisterHotKey(Handle, aatom);  GlobalDeleteAtom(aatom);end;procedure TForm1.RzBitBtnSetHotKeyClick(Sender: TObject);var  T: TShiftState;begin  if FindAtom('ZWXhotKey') = 0 then  begin    aatom := GlobalAddAtom('ZWXhotKey');  end;  ShortCutToKey(RzHotKeyEditSys.HotKey, Key, T);  Shift := ShiftStateToWord(T);
  try    if RegisterHotKey(Handle, aatom - $C000, Shift, Key) then    begin      ShowMessage('注册成功');    end;  except    on e: Exception do      ShowMessage(e.Message);
  end;
end;procedure TForm1.hotkey(var msg: TMessage);begin  if (msg.LparamLo = Shift) and (msg.LParamHi = Key) then  begin    ShowMessage('OK');  end;
end;

相关阅读 >>

Delphi的流操作的语法

Delphi firdac 对 sqlite 数字, int64也会被截断,会出现负数情况处理

Delphi中webbrowser的用法

Delphi 获得每个进程的cpu使用率

Delphi 正则表达式tperlregex 类的属性与方法

Delphi 系统对话框(如浏览目录)被隐藏到主窗体后面造成程序无法操作的临时处理方式

Delphi jpg文件合并器代码

Delphi解析json格式化的日期

Delphi不占cpu的延时函数

Delphi 给gmail发送邮件

更多相关阅读请进入《Delphi》频道 >>



在线咨询 拨打电话