Reputation: 4781
The ShortcutToText
function (in Delphi 7) returns the same result for shortcuts like Ctrl+1 as for Ctrl+Numpad 1.
How can I modify this function to return different result for numpad keys ?
Upvotes: 1
Views: 390
Reputation: 14873
The Virtual key codes for the numpad digit keys are VK_NUMPAD0 .. VK_NUMPAD9
as documented in MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
The ordinal values are $60 .. $69
. The VCL.Menus
function ShortcutToText
doesn't make a distinction between $30 .. $39
(which are the normal digit keys) and the numpad digit keys.
It should be trivial to write a function that does.
And @TLama already shows you how, change this:
$60..$69: Name := Chr(WordRec(ShortCut).Lo - $60 + Ord('0'));
Into this:
$60..$69: Name := 'Num' + Chr(WordRec(ShortCut).Lo - $60 + Ord('0'));
Upvotes: 5