|
马上注册并关注水世界微信号,获得更多资料
您需要 登录 才可以下载或查看,没有帐号?注册
扫一扫,用微信登录
x
本例要实现的是如何创建定制的菜单(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 |
|