GefContextMenuItem.Type (read-only property)

Gets the type of the menu item
Syntax: GefMenuItemTypeEnum = object.Type
Description: The Type property gets the type of the menu item.

Example:

Sub OnPreContextMenu(oContextMenu As GefContextMenu)
  ' Remove all native and point target menu items
  Dim cnt As Long
  
  cnt = oContextMenu.MenuItems.Count
  
  Dim types() As Long
  
  ReDim types(0 To cnt)
  Dim oContextMenuItem As GefContextMenuItem
  Dim oMenuItems As GefContextMenuItems
  
  Set oMenuItems = oContextMenu.MenuItems
  Dim index As Long
  index = 0
  For Each oContextMenuItem in oMenuItems
    types(index) = oContextMenuItem.Type
    index = index + 1
  Next oContextMenuItem
  Dim curType As Long
  Dim prevType As Long
  prevType = gefMenuItemTypeSeparator
  
  ' Go from back to front so that indexs are not
  ' invalidated as the menu is trasversed
  For index = cnt - 1 To 0 Step -1
    curType = types(index)
    If curType = gefMenuItemTypeNativeCommand Or _
      curType = gefMenuItemTypePointTarget Then
        oMenuItems.Remove index
    Else
      If curType = gefMenuItemTypeSeparator And prevType = gefMenuItemTypeSeparator Then
        oMenuItems.Remove index
      Else
        prevType = curType
      End If
    End If
  Next index
 
  'If the menu starts with a separator remove it
  If oMenuItems.Count > 0 Then
    If oMenuItems.Item(0).Type = gefMenuItemTypeSeparator Then
      oMenuItems.Remove 0
    End If
  End If
End Sub