做了一个类似于QQ热键的东西。但修改一个热键后。怎么注销掉前一个热键呢?

yanbing3456 2007-09-20 10:04:40
注册了一个热键

我换了个热键 怎么把以前的反注册掉
...全文
371 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuin 2007-09-28
  • 打赏
  • 举报
回复
hotkey1是你注册热键时的ID

BOOL RegisterHotKey(
HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);
liuin 2007-09-28
  • 打赏
  • 举报
回复

UnRegisterHotKey(handle, HotKeyId1);
DeleteAtom(HotKeyID1);
yanbing3456 2007-09-20
  • 打赏
  • 举报
回复
谢谢 楼上的

但这代码不是我要的

我的是想反注册到前一个热键

明白我说的吗?

你的代码热键 ctrl+F1 客户修改了一个热键
把CRTL+F1 反注册 并注册客户自己设定的热键
cncharles 2007-09-20
  • 打赏
  • 举报
回复

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FMyAtom: TAtom;
//添加全局热键 CTRL + F1
procedure AddHotKey;
//删除全局热键
procedure DeleteHotKey;
procedure WMHotKey(var Msg: TWMHotKey); message WM_HotKey;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AddHotKey;
begin
FMyAtom := GlobalFindAtom('Hot1');
if FMyAtom = 0 then begin
FMyAtom := GlobalAddAtom('Hot1');
if RegisterHotKey(Handle, FMyAtom, MOD_Control, VK_F1) then
ShowMessage('Register hot key success!');
end else
ShowMessage('CTRL + F1 has been registered');
end;

procedure TForm1.DeleteHotKey;
begin
if FMyAtom <> 0 then begin
UnRegisterHotKey(Handle, FMyAtom);
GlobalDeleteAtom(FMyAtom);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
AddHotKey;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
DeleteHotKey;
end;

procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = FMyAtom then begin
ShowMessage('Call from hotkey');
end;
end;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧