Setting THKKey to VK_NEXT will display "NUM 3"

A very simple test case:

alt text http://17slon.com/krama/hotkey.png

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

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

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

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

Does anyone know a good workaround? Currently, the only idea I got is to send fake WM_KEYDOWN / WM_KEYUP messages with parameters set to VK_NEXT and MapVirtualKey (VK_NEXT), but it's pretty ugly ...


- 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
+3
1

hkExt :

HotKey2.HotKey := HotKey1.HotKey;
HotKey2.Modifiers := HotKey1.Modifiers;
+13

Source: https://habr.com/ru/post/1751528/


All Articles