我一直在尝试注册3个热键。 我跟着this的例子(或this)。无法注册多个全局热键
如果我注册一个热键,代码正在工作。 但是,如果我尝试注册3个热键,只有最后一个登记的工作:
procedure TFrmSettings.FormCreate;
begin
atomN:= GlobalAddAtom(pchar('atomN'));
atomT:= GlobalAddAtom(pchar('atomT'));
atomH:= GlobalAddAtom(pchar('atomH'));
end;
procedure TFrmSettings.test1;
begin
RegisterHotShortCut(Handle, atomN, hotN.HotKey); // first registered
RegisterHotShortCut(Handle, atomH, hotH.HotKey); // second registered
RegisterHotShortCut(Handle, atomT, hotT.HotKey); // third - only this works
end;
RegisterHotShortCut在网页中宣布上述。
function RegisterHotShortCut(const h:THandle; const Atom: integer; const ShortCut: TShortCut): Boolean;
VAR
key : Word;
Shift: TShiftState;
begin
Windows.UnregisterHotKey(h, Atom);
ShortCutToKey(ShortCut, key, shift);
Result:= RegisterHotKey(h, Atom, ShiftState2Modifier(Shift), key);
end;
如果在上面的代码中,我评论最后一行,那么上一个热键(hotH)正在工作。这意味着我宣布一切正常,但最后一个热键控制了(取消注册)其他热键。
或者用其他方式说出来,按第一个注册快捷方式的组合键不会使程序输入TFrmSettings.HotyKeyMsg(VAR msg: TMessage)
过程。
任何提示? 谢谢。
EDIT1:
有迹象表明,似乎对其他工作,简单的代码片段,但我真的需要让用户更改快捷方式,所以我需要的ShortCutToKey程序。
我应该为每个全局快捷方式声明一个原子。对?
EDIT2: 解决 上面的代码失败,只有当我使用 “GlobalAddAtom” 功能。如果我不使用原子,而只使用数字1,2和3,那么代码就可以工作。如果我使用4,5,6,代码将再次失败。 问题(半)解决。
嗨。 RegisterHotShortCut在上面提到的网页中声明。 – Ampere 2009-04-13 11:17:56
糟糕,是的,你是正确的,我看到你现在已经把它包含在问题中了。恐怕我不能进一步帮助。 – hlovdal 2009-04-13 11:51:11
无论如何感谢您的帮助。 – Ampere 2009-04-13 11:58:04