Show: Delphi C++
Display Preferences

Vcl.Menus.NewItem

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function NewItem(const ACaption: string; AShortCut: TShortCut; AChecked, AEnabled: Boolean; AOnClick: TNotifyEvent; hCtx: THelpContext; const AName: string): TMenuItem;

C++

extern DELPHI_PACKAGE TMenuItem* __fastcall NewItem(const System::UnicodeString ACaption, System::Classes::TShortCut AShortCut, bool AChecked, bool AEnabled, System::Classes::TNotifyEvent AOnClick, System::Classes::THelpContext hCtx, const System::UnicodeString AName);

Properties

Type Visibility Source Unit Parent
function public
Vcl.Menus.pas
Vcl.Menus.hpp
Vcl.Menus Vcl.Menus

Description

Creates and initializes a menu item.

Call NewItem to create and initialize a menu item when constructing a menu programmatically.

The Caption 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 run time, 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 Examples

Personal tools
In Other Languages
Previous Versions
Assistance