com.esri.arcgis.controls
Interface IToolbarMenu

All Superinterfaces:
Serializable
All Known Subinterfaces:
IToolbarMenu2
All Known Implementing Classes:
ToolbarMenu

public interface IToolbarMenu
extends Serializable

Provides access to members that control ToolbarControl menu items.

Superseded By

IToolbarMenu2

Description

A ToolbarMenu supplies the implementation of a menu item that can host Command, Tool, ToolControl, MultiItem and ToolbarPalette objetcs. A ToolbarMenu can either be hosted on the ToolbarControl or can appear as a popup menu.

A ToolbarMenu can be built in two ways. Firstly, an object implementing IMenuDef can be passed to the IToolbarControl::AddItem or IToolbarControl::AddMenuItem method which creates a ToolbarMenu object and populates it from the menu definition. Secondly, the properties and methods on the IToolbarMenu interface can be used to build a menu. Any sub menus on a ToolbarMenu are implemented as another instance of a IToolbarMenu.

Remarks

ToolbarMenu items support accelerator (shortcut) and access keys, defined in the ICommand::Caption property. For example, a 'Close' command with the caption "&Close\tAlt+F4" has the 'ALT+F4' key combination as its shortcut key, and the 'C' key as its access key. Although a shortcut key will always work, an access key will only work when the ToolbarMenu is active.

Product Availability

Available with ArcGIS Engine.


Method Summary
 int addItem(Object item, int subType, int index, boolean beginGroup, int style)
          Adds an item to the ToolbarMenu.
 int addSubMenu(Object menuOrPalette, int index, boolean beginGroup)
          Adds a sub-menu to the ToolbarMenu.
 int find(Object item)
          Returns the index of the first item containing the given command or menu.
 int getBitmap()
          The bitmap that is used as the icon on this ToolbarMenu.
 String getCaption()
          The caption used by the ToolbarMenu.
 ICommandPool getCommandPool()
          The CommandPool used by the ToolbarMenu.
 int getCount()
          The number of items on the ToolbarMenu.
 Object getHook()
          The object that is passed as a hook to the OnCreate event of each item's command.
 IToolbarItem getItem(int index)
          Returns the item at the specified index from the ToolbarMenu.
 IMenuDef getMenuDef()
          Returns the menu definition, this method is obsolete.
 void moveItem(int startIndex, int finalIndex)
          Moves an item from one index to another.
 void popupMenu(int x, int y, int hWndParent)
          Pops up the menu at the position specified.
 void remove(int index)
          Removes the item at the specified index from the ToolbarMenu.
 void removeAll()
          Removes all items from the ToolbarMenu.
 void setBitmap(int pVal)
          The bitmap that is used as the icon on this ToolbarMenu.
 void setCaption(String pCaption)
          The caption used by the ToolbarMenu.
 void setCommandPoolByRef(ICommandPool ppCommandPool)
          The CommandPool used by the ToolbarMenu.
 void setHook(Object pHook)
          Sets the object that is passed as a hook to the OnCreate event of each item's command.
 

Method Detail

popupMenu

void popupMenu(int x,
               int y,
               int hWndParent)
               throws IOException,
                      AutomationException
Pops up the menu at the position specified.

Description

Creates a popup menu of the ToolbarMenu at the specified coordinates, supplied in pixels, relative to the top left of the parent window handle hWndParent.

The PopupMenu method is called automatically if the ToolbarMenu is hosted on the ToolbarControl, and the user has clicked on the menu item. In such cases the ToolbarMenu pops up just below the item.

If the ToolbarMenu is a standalone popup menu use the SetHook method, and optionally share the CommandPool with an existing one within the application.

Product Availability

Available with ArcGIS Engine.

Parameters:
x - The x (in)
y - The y (in)
hWndParent - The hWndParent (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setCaption

void setCaption(String pCaption)
                throws IOException,
                       AutomationException
The caption used by the ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Parameters:
pCaption - The pCaption (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCaption

String getCaption()
                  throws IOException,
                         AutomationException
The caption used by the ToolbarMenu.

Description

The Caption of the ToolbarMenu that is displayed on the ToolbarControl.

Product Availability

Available with ArcGIS Engine.

Returns:
The pCaption
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setCommandPoolByRef

void setCommandPoolByRef(ICommandPool ppCommandPool)
                         throws IOException,
                                AutomationException
The CommandPool used by the ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Parameters:
ppCommandPool - A reference to a com.esri.arcgis.controls.ICommandPool (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCommandPool

ICommandPool getCommandPool()
                            throws IOException,
                                   AutomationException
The CommandPool used by the ToolbarMenu.

Description

The CommandPool manages the collection of commands used by the ToolbarMenu. If the ToolbarMenu is added to the ToolbarControl the CommandPool will be shared with the IToolbarControl::CommandPool, otherwise a new CommandPool is created with a Hook property set to Nothing. If the ToolbarMenu is to be a popup menu, set the CommandPool to the IToolbarControl::CommandPool in order to share CommandPools.

Product Availability

Available with ArcGIS Engine.

Returns:
A reference to a com.esri.arcgis.controls.ICommandPool
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setHook

void setHook(Object pHook)
             throws IOException,
                    AutomationException
Sets the object that is passed as a hook to the OnCreate event of each item's command.

Description

The Hook is a shortcut to ICommandPoolEdit::Hook on the CommandPool. If the ToolbarMenu is an item on the ToolbarControl the Hook is shared and initialized by the ToolbarControl. If the ToolbarMenu is a standalone popup menu use the SetHook method, and optionally share the CommandPool with an existing one within the application.

Product Availability

Available with ArcGIS Engine.

Parameters:
pHook - A reference to another Automation Object (IDispatch) (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getHook

Object getHook()
               throws IOException,
                      AutomationException
The object that is passed as a hook to the OnCreate event of each item's command.

Description

The Hook is a shortcut to ICommandPoolEdit::Hook on the CommandPool.

Product Availability

Available with ArcGIS Engine.

Returns:
A reference to another Automation Object (IDispatch)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getBitmap

int getBitmap()
              throws IOException,
                     AutomationException
The bitmap that is used as the icon on this ToolbarMenu.

Description

The Bitmap of the ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Returns:
The pVal (A COM typedef)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

setBitmap

void setBitmap(int pVal)
               throws IOException,
                      AutomationException
The bitmap that is used as the icon on this ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Parameters:
pVal - The pVal (A COM typedef) (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getMenuDef

IMenuDef getMenuDef()
                    throws IOException,
                           AutomationException
Returns the menu definition, this method is obsolete.

Description

Returns the IMenuDef object from the ToolbarMenu. The ToolbarMenu will construct an object implementing IMenuDef that describes the current layout of the menu. Note that this a different object from that used to initially build the menu.

Product Availability

Available with ArcGIS Engine.

Returns:
A reference to a com.esri.arcgis.systemUI.IMenuDef
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

addItem

int addItem(Object item,
            int subType,
            int index,
            boolean beginGroup,
            int style)
            throws IOException,
                   AutomationException
Adds an item to the ToolbarMenu.

Description

A ToolbarMenu supplies the implementation of a menu item that can host commands, menus, palettes and multi-items.

Takes the specified command, menu or palette and creates new items that are appended to the ToolbarMenu with their Command set, and returns the index of the first item added. Specifiy the command, menu or palette as either a IUid, ProgID, ICommand , IMenuDef or IPaletteDef. To add a sub menu use the AddSubMenu method. To add a MultiItem use the IToolbarMenu2::AddMultiItem method. Note a palette object will be automatically added as a sub menu.

Supply a subType when passing an ICommandSubType. If no subType is supplied and the command is passed as a IUid or ProgID then ICommandSubType::GetCount determines the number of item's to be added to the ToolbarMenu. A subType must be supplied when passing an ICommandSubType as an ICommand, or the method will fail. By default subType is 0.

Index determines the position on the ToolbarMenu that the Item will be added to. By default this is -1 and represents the end of the ToolbarMenu.

beginGroup determines whether a separator will appear before the Item. By default beginGroup is False.

Style determines the style of the Item.

Remarks

AddItem checks to see if the supplied command or the commands used by the menu already exists in the CommandPool used by the ToolbarMenu. If the command does not already exist, it is created and added to the CommandPool with a ICommandPool::UsageCount of 1, and is set as the IToolbarItem::Command . If the command already exists in the CommandPool its ICommandPool::UsageCount is incremented by 1 and the command is set as the IToolbarItem::Command. The ICommand::OnCreate method will be called the first time a command is added to the CommandPool.

Where possible always supply commands and menus as either Uid objects or ProgID's. Only supply commands as ICommand or IMenuDef objects when a IUid or ProgID does not exist, and the class is compiled as part of the same project using the ToolbarControl. Passing a command or menu as an ICommand or IMenuDef object has the following limitation: Multiple instances of the same command can be added to the CommandPool , and each IToolbarItem::Command will point to a different command object.

Product Availability

Available with ArcGIS Engine.

Parameters:
item - A Variant (in)
subType - The subType (in, optional, pass 0 if not required)
index - The index (in, optional, pass -1 if not required)
beginGroup - The beginGroup (in, optional, pass false if not required)
style - A com.esri.arcgis.systemUI.esriCommandStyles constant (in, optional, pass 2 if not required)
Returns:
The itemIndex
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

addSubMenu

int addSubMenu(Object menuOrPalette,
               int index,
               boolean beginGroup)
               throws IOException,
                      AutomationException
Adds a sub-menu to the ToolbarMenu.

Description

Takes the specified menu and creates a new sub menu that is added to the ToolbarMenu, and returns the index of the menu. Specifiy the menu as either a IUid, ProgID, IMenuDef or IToolbarMenu.

Index determines the position on the ToolbarMenu that the Item will be added to. By default this is -1 and represents the end of the ToolbarMenu.

beginGroup determines whether a separator will appear before the Item. By default beginGroup is False.

Remarks

AddSubMenu checks to see if the commands used by the menu already exists in the CommandPool used by the ToolbarMenu. If the command does not already exist, it is created and added to the CommandPool with a ICommandPool::UsageCount of 1, and is set as the IToolbarItem::Command . If the command already exists in the CommandPool its ICommandPool::UsageCount is incremented by 1 and the command is set as the IToolbarItem::Command. The ICommand::OnCreate method will be called the first time a command is added to the CommandPool.

Where possible always supply commands and menus as either Uid objects or ProgID's. Only supply commands as ICommand or IMenuDef objects when a IUid or ProgID does not exist, and the class is compiled as part of the same project using the ToolbarControl.

Product Availability

Available with ArcGIS Engine.

Parameters:
menuOrPalette - A Variant (in)
index - The index (in, optional, pass -1 if not required)
beginGroup - The beginGroup (in, optional, pass false if not required)
Returns:
The itemIndex
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

remove

void remove(int index)
            throws IOException,
                   AutomationException
Removes the item at the specified index from the ToolbarMenu.

Description

Removes the item at the specified index from the ToolbarMenu. The item at the top of the menu as an index of 0.

Remarks

The Remove method will automatically find the IToolbarItem::Command in the CommandPool and decrement the ICommandPool::UsageCount by 1. If the ICommandPool::UsageCount reaches 0 the command will be released from the CommandPool.

Product Availability

Available with ArcGIS Engine.

Parameters:
index - The index (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

removeAll

void removeAll()
               throws IOException,
                      AutomationException
Removes all items from the ToolbarMenu.

Description

This method removes all items from the ToolbarMenu.

Remarks

For each item removed the RemoveAll method will automatically find the IToolbarItem::Command in the CommandPool and decrement the ICommandPool::UsageCount by 1. If the ICommandPool::UsageCount reaches 0 the command will be released from the CommandPool.

Product Availability

Available with ArcGIS Engine.

Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getItem

IToolbarItem getItem(int index)
                     throws IOException,
                            AutomationException
Returns the item at the specified index from the ToolbarMenu.

Description

The property is used to access a particular item on the ToolbarMenu. The item at the top of the menu has an index of 0.

Remarks

To loop through a ToolbarMenus item collection use the GetItem method in conjunction with the Count property.

Product Availability

Available with ArcGIS Engine.

Parameters:
index - The index (in)
Returns:
A reference to a com.esri.arcgis.controls.IToolbarItem
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCount

int getCount()
             throws IOException,
                    AutomationException
The number of items on the ToolbarMenu.

Description

Returns the number of items on the ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Returns:
The count
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

find

int find(Object item)
         throws IOException,
                AutomationException
Returns the index of the first item containing the given command or menu. Returns -1 if it is not found.

Description

Returns the index of the first item on the ToolbarMenu using the specified IUid , ProgID, ICommand or IToolbarMenu. If the specified comman, menu or palette cannot be found -1 is returned.

Remarks

To find an Item on the ToolbarMenu using a Command implementing ICommandSubType pass a UID with its SubType property set.

Product Availability

Available with ArcGIS Engine.

Parameters:
item - A Variant (in)
Returns:
The pVal
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

moveItem

void moveItem(int startIndex,
              int finalIndex)
              throws IOException,
                     AutomationException
Moves an item from one index to another.

Description

Moves the item at the specified startIndex, to the position at the specified finalIndex. If no finalIndex is supplied the item is moved to the end of the ToolbarMenu.

Product Availability

Available with ArcGIS Engine.

Parameters:
startIndex - The startIndex (in)
finalIndex - The finalIndex (in, optional, pass -1 if not required)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.