1.不能单独的Ctrl/Shift/Alt键(不过可以做出这效果来,自己研究吧)2.既然想知道值与hotkey值转换,那就简单的解释一下,先看这三个组合键值定义(16进制): scShift = $2000; scCtrl = $4000; scAlt = $8000; 这3个的值是2倍的关系,即10进制分别表示为8192,16384,32768 加上键盘上的字母和数字(或其它符号键),自己查一下ASCII码吧 比如A是65,就可以组合成hotkey值了,即8192+65=8257就是Shift+A反之任意给一个LongInt值,经过下面这个算法的运算,就得出它的hotkey值(比如16452,结果是Ctrl+D) 这是源码,不知道楼主能否看的懂(一些与运算而已): procedure TCustomHotKey.ShortCutToHotKey(Value: TShortCut); begin FHotKey := Value and not (scShift + scCtrl + scAlt); FModifiers := []; if Value and scShift <> 0 then Include(FModifiers, hkShift); if Value and scCtrl <> 0 then Include(FModifiers, hkCtrl); if Value and scAlt <> 0 then Include(FModifiers, hkAlt); end;
scShift = $2000;
scCtrl = $4000;
scAlt = $8000;
这3个的值是2倍的关系,即10进制分别表示为8192,16384,32768
加上键盘上的字母和数字(或其它符号键),自己查一下ASCII码吧
比如A是65,就可以组合成hotkey值了,即8192+65=8257就是Shift+A反之任意给一个LongInt值,经过下面这个算法的运算,就得出它的hotkey值(比如16452,结果是Ctrl+D)
这是源码,不知道楼主能否看的懂(一些与运算而已):
procedure TCustomHotKey.ShortCutToHotKey(Value: TShortCut);
begin
FHotKey := Value and not (scShift + scCtrl + scAlt);
FModifiers := [];
if Value and scShift <> 0 then Include(FModifiers, hkShift);
if Value and scCtrl <> 0 then Include(FModifiers, hkCtrl);
if Value and scAlt <> 0 then Include(FModifiers, hkAlt);
end;