Menus.NewSubMenu

From RAD Studio VCL Reference
Jump to: navigation, search

Contents

Delphi Information

From Menus.pas

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


Unit: Menus

Type: function

Visibility: public

C++ Information

From Menus.hpp

	Menus::TMenuItem * __fastcall NewSubMenu(System::UnicodeString ACaption,
		int hCtx,
		System::UnicodeString AName,
		Menus::TMenuItem * const * Items,
		int Items_Size,
		bool AEnabled);


Unit: Menus

Type: function

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 runtime.

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 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 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

Personal tools
Translations
Newest Version