开发者

Setting THotKey to VK_NEXT results in "NUM 3" being displayed

开发者 https://www.devze.com 2023-01-05 01:34 出处:网络
A very simple test case: (source: 17slon.com) procedure TForm3.btnCopyClick(Sender: TObject); begin HotKey2.HotKey := HotKey1.HotKey;

A very simple test case:

Setting THotKey to VK_NEXT results in "NUM 3" being displayed

(source: 17slon.com)

procedure TForm3.btnCopyClick(Sender: TObject);
begin
  HotKey2.HotKey := HotKey1.HotKey;
end;

Press "PgDn" key in the first THotKey and "Page Down" is displayed. Click the ==> button and the second THotKey will display "Num 3".

Similar things happen if modifiers (Shift etc) are pressed. The behaviour also applies to PgUp, Home, End and Ins.

As far as I can see, this happens somewhere inside Windows :( Correct virtual code (34) is sent along the HKM_SETHOTKEY message.

Does somebody know of a nice workaround? Currently, the only idea I g开发者_如何学Goot is to send fake WM_KEYDOWN/WM_KEYUP messages with parameters set to VK_NEXT and MapVirtualKey(VK_NEXT) but that is kinda ugly ...


Hotkeys are just simple 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
  end


The hkExt modifier is important and needs to be copied, too:

HotKey2.HotKey := HotKey1.HotKey;
HotKey2.Modifiers := HotKey1.Modifiers;
0

精彩评论

暂无评论...
验证码 换一张
取 消