全局热键的一些知识

//全局热键的一些知识,程序快捷键也要用到原子。

TmpID:Integer;
begin
TmpID:=GlobalFindAtom(‘MyHotkey’);
if TmpID=0 then //查找全局原子.如果返回值不为0,则说明这个全局原子已经被注册;
id:=GlobalAddAtom(‘MyHotkey’)
else
ID:=TmpID;
TmpID:=GlobalFindAtom(‘MyHotkey2′);
if tmpid=0 then
id2:=globaladdatom(‘MyHotkey2′)
else
id2:=TmpID;

TmpID:=GlobalFindAtom(‘MyHotkey3′);
if tmpid=0 then
id3:=globaladdatom(‘MyHotkey3′)
else
id3:=TmpID;

TmpID:=GlobalFindAtom(‘MyHotkey4′);
if tmpid=0 then
id4:=globaladdatom(‘MyHotkey4′)
else
id4:=TmpID;
RegisterHotKey(Handle, id, 0, $70); //注册热键:
RegisterHotKey(Handle, id2, 0, $71); //注册热键:
RegisterHotKey(Handle, id3, 0, $72); //注册热键:
RegisterHotKey(Handle, id4, 0, $73); //注册热键:
untPublicUnit.h:=untPublicUnit.opencomm(1,2400);
EditRegID.Text:=untPublicUnit.MarkAddDate;

procedure TfrmRegister.WMHotKey(var Msg: TWMHotKey);
begin
if msg.HotKey=ID then //热键esc的消息.
untPublicUnit.voicehanshu(1,”);
if msg.HotKey=id2 then
untPublicUnit.voicehanshu(4,”);
if msg.HotKey=id3 then
untPublicUnit.voicehanshu(10,”);
if msg.HotKey=id4 then
untPublicUnit.voicehanshu(11,”);

end;

procedure TfrmRegister.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(Handle,ID);//释放热键
GlobalDeleteAtom(ID); //删除全局原子ID
UnregisterHotKey(Handle,ID2);//释放热键
GlobalDeleteAtom(ID2); //删除全局原子ID
UnregisterHotKey(Handle,ID3);//释放热键
GlobalDeleteAtom(ID3); //删除全局原子ID
UnregisterHotKey(Handle,ID4);//释放热键
GlobalDeleteAtom(ID4); //删除全局原子ID
end;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值