『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

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

本例要实现的是如何创建定制的菜单(Menu)
用户通过在类模块中实现IMenuDef接口来创建定制的菜单(Menu),如果要使菜单出现在Customize Dialog的Menus类型中。

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

       l 要点

       用户通过在类模块中实现IMenuDef接口来创建定制的菜单(Menu),如果要使菜单出现在Customize DialogMenus类型中,必须同时实现IrootLevelMenu接口,它表明菜单为root menuIMenuDef接口包括 CaptionItemCountName三个属性和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

      京ICP备2025132830号-1 京公网安备 号