http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> ArcGIS >> ArcObjects开发 >> 正文

本例要实现的是如何创建定制的菜单(Menu)

作者:gis    文章来源:GIS帝国    点击数:    更新时间:2007-9-22
摘要:

本例要实现的是如何创建定制的菜单(Menu)

l 要点

用户通过在类模块中实现IMenuDef接口来创建定制的菜单(Menu),如果要使菜单出现在Customize Dialog的Menus类型中,必须同时实现IrootLevelMenu接口,它表明菜单为root menu。IMenuDef接口包括 Caption、ItemCount及Name三个属性和GetItemInfo方法。类似IToolBarDef(参照1.2.3)

l 程序说明

程序在类模块中实现IMenuDef接口来创建定制的菜单(Menu)。

l 代码

Option Explicit

'Implement the IMenuDef interface and IRootLevelMenu interface
Implements IMenuDef
Implements IRootLevelMenu

Private Property Get IMenuDef_Caption() As String
     ' Set the string that appears as the menu's title
     IMenuDef_Caption = "MyMenu"
End Property

Private Sub IMenuDef_GetItemInfo(ByVal pos As Long, _
ByVal itemDef As esriCore.IItemDef)
     ' Define the commands that will be on the menu. The built-in ArcMap
     ' Full Extent command, and Fixed Zoom In command are added to this custom menu.
     ' ID is the ClassID of the command. Group determines whether the command
     ' begins a new group on the menu
     Select Case pos
     Case 0
         itemDef.ID = "promenu.clsmultitem"
         itemDef.Group = False
     Case 1
         itemDef.ID = "esriCore.FullExtentCommand"
         itemDef.Group = True
     Case 2
         itemDef.ID = "esriCore.ZoomInFixedCommand"
         itemDef.Group = False
     End Select
End Sub

Private Property Get IMenuDef_ItemCount() As Long
     ' Set how many commands will be on the menu
     IMenuDef_ItemCount = 3
End Property

Private Property Get IMenuDef_Name() As String
     ' Set the internal name of the menu.
     IMenuDef_Name = "MyMenu"
End Property

Tags:ArcMap VBA  
责任编辑:wzj3sstudio
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图