AnnMenu example for Visual Basic
Note: This topic is for Document/Medical only.
Private Sub LEAD1_AnnMenu(ByVal AnnMenu As LEADLib.IAnnMenu)
Dim nID As Integer
Dim x As Integer
Dim PopupMenuItem As LEADLib.IAnnMenu
MsgBox "There are " & CStr(AnnMenu.count) & " Items"
MsgBox "Original Text for item#2: " & AnnMenu.ItemString(1)
'set new string
AnnMenu.ItemString(1) = "TestText"
MsgBox "Custom Text for item#2: " & AnnMenu.ItemString(1)
'make 3rd and 4th menu items have the same command id
nID = AnnMenu.ItemID(3)
AnnMenu.ItemID(2) = nID
'check all unchecked menu items that are not popup submenus
'disable all enabled menu items that are not popup submenus
For x = 0 To AnnMenu.count - 1
If AnnMenu.ItemType(x) = ANNMENUITEMTYPE_NORMAL Then
If (AnnMenu.ItemChecked(x) = False) Then
AnnMenu.ItemChecked(x) = True
End If
If (AnnMenu.ItemEnabled(x) = True) Then
AnnMenu.ItemEnabled(x) = False
End If
End If
Next x
'insert 2 user-defined menu items
AnnMenu.AddItem "&Flip", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST, AnnMenu.count
AnnMenu.AddItem "Test&2", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 1, AnnMenu.count
'delete the last menu item
AnnMenu.DeleteItem AnnMenu.count - 1
'delete the first menu item
AnnMenu.DeleteItem 0
'insert a popup menu
AnnMenu.AddItem "&Popup1", ANNMENUITEMTYPE_SUBMENU, 0, AnnMenu.count
'get the new item, and add some items to it
Set PopupMenuItem = AnnMenu.GetSubMenu(AnnMenu.count - 1)
PopupMenuItem.AddItem "Test&1", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 2, PopupMenuItem.count
PopupMenuItem.AddItem "Test&2", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 3, PopupMenuItem.count
End Sub
Private Sub LEAD1_AnnUserMenu(ByVal nID As Long)
If nID = LTANNEVENT_MENUFIRST Then
LEAD1.AnnFlip False, 0, True
Else
MsgBox "nID = LTANNEVENT_MENUFIRST + " + CStr (nID - LTANNEVENT_MENUFIRST)
End If
End Sub