Click here for NewsObjects Overview
InsertContextMenuSubmenu Method
Windows - Visual C++


Description
The InsertContextMenuSubmenu method inserts a submenu into the control's context menu at a specified position.

Syntax
short result = InsertContextMenuSubmenu(short menuID, short insertPosition, LPCTSTR menuItemText);

The InsertContextMenuSubmenu syntax has these parts:

 Part

Description

menuID

A short integer containing the menu ID of the menu to address as described in Remarks.

insertPosition

A short integer containing the position in which to insert the submenu. insertPosition is one-based.

menuItemText

A String containing the text of the new submenu as described in Remarks.

result

Return value. A short integer containing the menu ID of the submenu that was created.

Remarks
The context menu is the menu that appears when you right click on the control. It can be turned on or off by setting the ContextMenuEnabled property. The context menu is initially empty; you add your preferred menu items to it using the ContextMenuItem methods.

The menuID parameter is used to indicate whether to address the main context menu or a submenu. The menuID of the main context menu is always 0. The menuID of a submenu is returned when the submenu is created with AppendContextMenuSubmenu or InsertContextMenuSubmenu. Note that this menuID has no relation to any ID used by the Windows API.

The menuItemText parameter can contain information about shortcut keys and accelerator keys. The format is the same as that used by the Windows API. For example,

&Close\tCtrl+W

will appear in the menu as

Close Ctrl+W

When the user types a shortcut key, for example, the letter 'C' for the Close menu item example above, it will be handled in the same way as if the user selected the menu item. The ContextMenu event will be fired. However, it is the container's job to handle any accelerator key combinations, for example, Ctrl+W in the example above.

See Also: AppendContextMenuItem AppendContextMenuSeparator AppendContextMenuSubmenu GetContextMenuItemCount InsertContextMenuItem InsertContextMenuSeparator RemoveContextMenuItem ContextMenu ContextMenuEnabled UpdateContextMenu

Back to: Headline Methods Quote Methods Story Methods