RAD Studio VCL Reference
|
Specifies the form's main menu.
property Menu: TMainMenu;
__property TMainMenu Menu;
Use Menu to get or set the form's main menu. At design time, Menu is set to the first TMainMenu component added to the form.
C++ Examples:
/* 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. Click on 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); }
/*
To create a toolbar that corresponds to an existing menu:
1 Drop a ToolBar on the form and add a ToolButton for each
top-level menu item you wish to create.
2 Set the MenuItem property of each ToolButton to correspond
to the top level menu items.
3 Set the Grouped property of each ToolButton to true.
4 Clear the Menu property of the Form (if it is assigned)
5 Set the Visible property on the ToolBar and ToolButtons to
true.
6 Set the ShowCaptions property on the ToolBar to true.
7 Set the MenuItem | Visible property of each ToolButton to
true.
*/
Delphi Examples:
{ 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;
{
To create a toolbar that corresponds to an existing menu:
1 Drop a ToolBar on the form and add a ToolButton for each top-level menu item you wish to create.
2 Set the MenuItem property of each ToolButton to correspond to the top level menu items.
3 Set the Grouped property of each ToolButton to true.
4 Clear the Menu property of the Form (if it is assigned)
5 Set the Visible property on the ToolBar and ToolButtons to true.
6 Set the ShowCaptions property on the ToolBar to true.
7 Set the MenuItem | Visible property of each ToolButton to true.
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|