delphi 如何设置热键


本文整理自网络,侵删。

 
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;
  end;
var
  Form1: TForm1;
  F9_ID,F10_ID:integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
  if GlobalFindAtom('MyF9HotKey') = 0 then
  begin
    F9_ID:=GlobalAddAtom('MyF9HotKey');
    RegisterHotKey(handle,F9_id,0,VK_F9);
  end;
  if GlobalFindAtom('MyF10HotKey') = 0 then
  begin
    F10_ID:=GlobalAddAtom('MyF10HotKey');
    RegisterHotKey(handle,F10_id,0,VK_F10);
  end ;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(handle,F9_id);
  GlobalDeleteAtom(F9_id);
  UnRegisterHotKey(handle,F10_id);
  GlobalDeleteAtom(F10_id);
end;
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
  if msg.HotKey = F9_id then form1.hide;
  if msg.HotKey = F10_id then form1.show;
end;
end.

相关阅读 >>

Delphi android实例-trectangle加载图片(xe8+小米2)

Delphi 建立快捷方式

Delphi webbrowser1 设置获取编码

Delphi 模糊查询和字段查询

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

Delphi xe6通过wifiapi得到wifi信息

学习使用Delphi for android 调用java类库

Delphi ip编辑控件

Delphi 计算文件与当前时间差(天小时分钟秒)

Delphi tms web core messagedlg对话框 yes no

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



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...