RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Menus.NewSubMenu Function

Creates and initializes a menu item that represents a submenu.

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

Menus

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.
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!