TCustomFormMenu (C++)

From RAD Studio Code Examples
Jump to: navigation, search


This code displays a new menu named MyMenu when you click the button. MyOnExecute must be included in the definition of the TForm1 class. Click the menu item or type CTRL+N to execute MyOnExecute.


void __fastcall TForm1::Button1Click(TObject *Sender)
  TMenuItem *Item1 = NewItem("New item", TextToShortCut("Ctrl+N"), false, true, MyOnExecute, 0, "Item1");
  Menu = NewMenu(this, "MyMenu", &Item1, 0);

void __fastcall TForm1::MyOnExecute(TObject *Sender)
  MessageDlg("Item1 has been executed.", mtInformation, TMsgDlgButtons() << mbOK, 0);