TCustomFormMenu (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This code displays a new menu named MyMenu when you click the button. MyOnExecute must be included in the definition of the TForm1 class.

Code

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;

Uses