Menus.NewItem
Contents |
Delphi Information
From Menus.pas
function NewItem(const ACaption: string; AShortCut: TShortCut; AChecked: Boolean; AEnabled: Boolean; AOnClick: TNotifyEvent; hCtx: THelpContext; const AName: string): TMenuItem;
Unit: Menus
Type: function
Visibility: public
C++ Information
From Menus.hpp
Menus::TMenuItem * __fastcall NewItem(System::UnicodeString ACaption, unsigned short AShortCut, bool AChecked, bool AEnabled, TNotifyEvent AOnClick, int hCtx, System::UnicodeString AName);
Unit: Menus
Type: function
Description
Creates and initializes a menu item.
Call NewItem to create and initialize a menu item when constructing a menu programmatically.
The ACaption parameter specifies the string that should appear for the menu item.
The AShortCut parameter specifies any associated shortcut.
The AChecked parameter indicates whether the menu item appears with a check mark.
The AEnabled parameter specifies whether the menu item is enabled or grayed.
The AOnClick parameter specifies an event handler that executes when the user clicks the menu item.
The hCtx parameter specifies the help context ID for the menu item.
The AName parameter specifies the name of the menu item, which can be used to refer to the menu item in code.
The menu item returned by NewItem can be added to a menu using the target parent's Add method. If the entire menu is being created dynamically at runtime, the new menu item can be added to an array that is passed as a parameter to the NewMenu, NewPopupMenu, or NewSubMenu function.
Warning: The item returned by NewItem does not have an owner. You are responsible for freeing its memory when it is no longer needed. The Delete and Remove methods of TMenuItem do not free memory.
See Also
Code Samples