这次得到了热键的名称但是反着的
目的: 按键后,我就要得到 【字符串型的Ctrl+Shift+Alt+1】unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.ComCtrls, Vcl.StdCtrls;
type
TForm1 = class(TForm)
HotKey1: THotKey;
Edit1: TEdit;
Edit2: TEdit;
HotKey2: THotKey;
procedure HotKey1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
Menus;
procedure TForm1.HotKey1Change(Sender: TObject);
var
Text: string;
begin
Edit1.Text := inttostr(HotKey1.HotKey); //获取得到的是对应的数值
Text := ShortcutToText(Hotkey1.Hotkey);
Edit2.Text := Text; //这次得到了热键的名称但是反着的
end;
end.
你要看源代码啊,ShortcutToText的显示顺序就是这样的,你要自己改成你想要的
function ShortCutToTextGeneric(ShortCut: TShortCut; Localized: boolean): string;
var
Name: string;
begin
Result := '';
Name := KeyCodeToKeyString(ShortCut and $FF, Localized);
if Name <> '' then
begin
if ShortCut and scShift <> 0 then Result := Result + KeyCodeToKeyString(scShift, Localized);
if ShortCut and scCtrl <> 0 then Result := Result + KeyCodeToKeyString(scCtrl, Localized);
if ShortCut and scMeta <> 0 then Result := Result + KeyCodeToKeyString(scMeta, Localized);
if ShortCut and scAlt <> 0 then Result := Result + KeyCodeToKeyString(scAlt, Localized);
Result := Result + Name;
end;
end;
function ShortCutToText(ShortCut: TShortCut): string;
begin
Result:=ShortCutToTextGeneric(ShortCut, true);
end;
页:
[1]