菜单项通过 ShortCut 属性来设定快捷键, ShortCut 是 TShortcut 类型的; TShortcut 是一个子界: 0..65535
ShortCut 的所有可选值请参加列表: http://www.cnblogs.com/del/archive/2008/02/04/1064631.html
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  MyMenu: TMainMenu;
  Item: TMenuItem;

procedure TForm1.FormCreate(Sender: TObject);
var
  Itemd: TMenuItem;
begin
  MyMenu := TMainMenu.Create(Self);
  MyMenu.AutoHotkeys := maManual;     
  Self.Menu := MyMenu;

  Item := TMenuItem.Create(MyMenu);
  Item.Caption := 'AA';               
  MyMenu.Items.Add(Item);

    Itemd := TMenuItem.Create(MyMenu);
    Itemd.Caption := 'A1';
    Itemd.ShortCut := 16449; {这一句话就为菜单项 A1 指定了快捷键: Ctrl+A }
    Item.Add(Itemd);
end;

end.

效果图:

TMainMenu 类[三] - 手动建立菜单(7) : 指定快捷键

相关文章:

  • 2022-12-23
  • 2021-11-24
  • 2021-12-31
  • 2022-12-23
  • 2021-10-20
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案