unit TCustomFormMenu;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure MyOnExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: TCustomFormMenu
// Property: Forms.TCustomForm.Menu
// Routine: Menus.NewMenu
// Routine: Menus.NewItem
// Routine: Menus.TextToShortCut

// BeginCode
{
This code displays a new menu named MyMenu when the user
clicks the button. MyOnExecute must be included in the
definition of the TForm1 class.
} 
procedure TForm1.Button1Click(Sender: TObject);
begin
  Menu := NewMenu(Self, 'MyMenu',
            [NewItem('New item', TextToShortCut('Ctrl+N'),
            False, True, MyOnExecute, 0, 'Item1')]);
end;

procedure TForm1.MyOnExecute(Sender: TObject);
begin
  MessageDlg('Item1 has been executed.', mtInformation, [mbOK], 0);
end;
// EndCode
// EndExample: TCustomFormMenu
end.
