一个非常简单的测试用例: alt text http://17slon.com/krama/hotkey.png procedure TForm3.btnCopyClick(Sender: TObject);begin HotKey2.HotKey := HotKey1.HotKey;end; 在第一个THOTKey中按“PgDn”键,显示“Page Down”.点击=
alt text http://17slon.com/krama/hotkey.png
procedure TForm3.btnCopyClick(Sender: TObject); begin HotKey2.HotKey := HotKey1.HotKey; end;
在第一个THOTKey中按“PgDn”键,显示“Page Down”.点击==>按钮和第二个THOTKey将显示“Num 3”.
如果按下修改器(Shift等),也会发生类似的事情.该行为也适用于PgUp,Home,End和Ins.
据我所见,这发生在Windows内部:(正确的虚拟代码(34)沿着HKM_SETHOTKEY消息发送.
有人知道一个很好的解决方法吗?目前,我得到的唯一想法是发送伪造的WM_KEYDOWN / WM_KEYUP消息,参数设置为VK_NEXT和MapVirtualKey(VK_NEXT),但这有点难看……
热键只是简单的THOTKeys:
object HotKey1: THotKey Left = 12 Top = 14 Width = 121 Height = 19 InvalidKeys = [] Modifiers = [] TabOrder = 0 end object HotKey2: THotKey Left = 194 Top = 14 Width = 121 Height = 19 InvalidKeys = [] Modifiers = [] TabOrder = 1 end object btnCopy: TButton Left = 143 Top = 14 Width = 42 Height = 19 Caption = '==>' TabOrder = 2 OnClick = btnCopyClick endhkExt修饰符很重要,也需要复制:
HotKey2.HotKey := HotKey1.HotKey; HotKey2.Modifiers := HotKey1.Modifiers;