我从一个新的 Delphi VCL 应用程序开始,将 Menus 添加到 uses 子句,在表单上放置一个标签,然后分配表单的 OnShortCut 事件:
procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
Label1.Caption := ShortCutToText(ShortCut(Msg.CharCode, KeyDataToShiftState(Msg.KeyData)));
end;
在 XP 上,这适用于我尝试过的所有快捷键组合,包括Shift++ 。在 Vista 和 Windows 7 上,测试应用程序显示++到++ ,但不显示++ 。其他组合,如+ ,+ ,甚至+ + +都显示得很好。Ctrl0ShiftCtrl1ShiftCtrl9ShiftCtrl0Shift0Ctrl0ShiftCtrlAlt0
在调试器下运行应用程序,我发现 OnShortCut 事件永远不会触发 Msg.CharCode = Ord('0') 如果在按下键时同时按住Shift和键。Ctrl0
Delphi IDE 在 Vista 下也有同样的问题。 Ctrl++设置书签1 ,但Shift++没有设置书签 0,这是应该的。1CtrlShift0
我已经使用 Delphi 2007 和 2010 在 VMware 中的 Windows Vista 和 7 的原始安装上对此进行了测试,因此没有第 3 方软件捕获密钥。我还没有尝试过任何其他开发工具来确定问题出在 Delphi 还是 Vista 本身。