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用socket api实现路由追踪

Delphi利用线程注入技术实现刷新流量

Delphi压缩图片代码

Delphi 用ini记录combobox的itemindex

如何使用Delphi 10 seattle的android应用做intent的发送和接收

Delphi datasnap传输流/文件问题

Delphi 内存读取、修改

Delphi 程序获取传参

Delphi cxgrid中回车键光标移到下列

download 和 http downloader 源码

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



打赏

取消

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

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

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

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

评论

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