Vcl.Menus.NewSubMenu

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function NewSubMenu(const ACaption: string; hCtx: THelpContext; const AName: string; const Items: array of TMenuItem; AEnabled: Boolean): TMenuItem;

C++

extern DELPHI_PACKAGE TMenuItem* __fastcall NewSubMenu(const System::UnicodeString ACaption, System::Classes::THelpContext hCtx, const System::UnicodeString AName, TMenuItem* const *Items, const int Items_High, bool AEnabled = true);

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 that represents a submenu.

Call NewSubMenu to create a menu item that represents a submenu when constructing a menu programmatically at run time.

The ACaption parameter indicates the string that appears in the parent menu for the submenu.

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 Items parameter specifies an array of menu items that make up the submenu and that appear when the user clicks the submenu item in the parent menu.

Note: The Items_Size parameter specifies the index of the last menu item in Items (one less than the number of menu items).

The AEnabled parameter specifies whether the menu item that appears in the parent menu is enabled.

Once a submenu has been created using NewSubMenu, it 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 NewSubMenu 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