AnnMenu example for C++ 4.0 and later
Note: This topic is for Document/Medical only.
void CAnntestDlg::OnAnnMenuLeadctrl1(LPDISPATCH AnnMenu)
{
long nID;
short x;
CString csOut;
CAnnMenu AnnMenuMain(AnnMenu);
csOut.Format("There are %ld Items", AnnMenuMain.GetCount());
AfxMessageBox(csOut);
csOut = "Original Text for item#2: " + AnnMenuMain.GetItemString(1);
AfxMessageBox(csOut);
//set new string
AnnMenuMain.SetItemString(1, "TestText");
csOut = "Custom Text for item#2: " + AnnMenuMain.GetItemString(1);
AfxMessageBox(csOut);
//make 3rd and 4th menu items have the same command id
nID = AnnMenuMain.GetItemID(3);
AnnMenuMain.SetItemID(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; x<AnnMenuMain.GetCount(); x++)
{
if(AnnMenuMain.GetItemType(x) == ANNMENUITEMTYPE_NORMAL)
{
if(!AnnMenuMain.GetItemChecked(x))
AnnMenuMain.SetItemChecked(x, TRUE);
if(AnnMenuMain.GetItemEnabled(x))
AnnMenuMain.SetItemEnabled(x, FALSE);
}
}
//insert 2 user-defined menu items
AnnMenuMain.AddItem("&Flip", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST, AnnMenuMain.GetCount());
AnnMenuMain.AddItem("Test&2", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 1, AnnMenuMain.GetCount());
//delete the last menu item
AnnMenuMain.DeleteItem(AnnMenuMain.GetCount() - 1);
//delete the first menu item
AnnMenuMain.DeleteItem(0);
//insert a popup menu
AnnMenuMain.AddItem("&Popup1", ANNMENUITEMTYPE_SUBMENU, 0, AnnMenuMain.GetCount());
//get the new item, and add some items to it
CAnnMenu PopupMenuItem;
PopupMenuItem = AnnMenuMain.GetSubMenu(AnnMenuMain.GetCount() - 1);
PopupMenuItem.AddItem("Test&1", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 2, PopupMenuItem.GetCount());
PopupMenuItem.AddItem("Test&2", ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 3, PopupMenuItem.GetCount());
AnnMenuMain.DetachDispatch();
}
void CAnntestDlg::OnAnnUserMenuLeadctrl1(long nID)
{
if (nID == LTANNEVENT_MENUFIRST)
m_Lead1.AnnFlip (FALSE, 0.0f, TRUE);
else
{
CString str;
str.Format("nID = LTANNEVENT_MENUFIRST + %d", nID – LTANNEVENT_MENUFIRST);
MessageBox(str);
}
}