M
Mark Jailan
Hello,
I've created an Add-On using C++ and installed my own menu items using
some sample code. This code adds the "MyNewMenu" right after the
"Shape" menu, and creates the "MyNewMenuItem" item under it.
My question is, how do I write code to respond to this Event? I can't
find any documentation or sample code.
Here's the code to add a Menu item ...
// Get a UIObject object that represents Visio built-in menus.
Visio::IVUIObjectPtr vsoUIObject = app->GetBuiltInMenus();
// Get the MenuSets collection.
Visio::IVMenuSetsPtr vsoMenuSets = vsoUIObject->GetMenuSets();
// Get the drawing window menu set.
Visio::IVMenuSetPtr vsoMenuSet =
vsoMenuSets->GetItemAtID(visUIObjSetDrawing);
// Get the Menus collection.
Visio::IVMenusPtr vsoMenus = vsoMenuSet->GetMenus();
// Add a new menu before the Window menu.
Visio::IVMenuPtr vsoMenu = vsoMenus->AddAt(7);
vsoMenu->PutCaption(_bstr_t("MyNewMenu"));
// Get the MenuItems collection.
Visio::IVMenuItemsPtr vsoMenuItems = vsoMenu->GetMenuItems();
// Add a menu item to the new menu.
Visio::IVMenuItemPtr vsoMenuItem = vsoMenuItems->Add();
// Set the Caption property for the new menu item.
vsoMenuItem->PutCaption(_bstr_t("&MyNewMenuItem"));
// Tell Visio to use the new UI when the document is active.
Visio::IVDocumentsPtr vsoDocuments = app->GetDocuments();
Visio::IVDocumentPtr vsoDocument =
vsoDocuments->GetItem(_variant_t(1));
vsoDocument->SetCustomMenus(vsoUIObject);
Regards,
Mark
I've created an Add-On using C++ and installed my own menu items using
some sample code. This code adds the "MyNewMenu" right after the
"Shape" menu, and creates the "MyNewMenuItem" item under it.
My question is, how do I write code to respond to this Event? I can't
find any documentation or sample code.
Here's the code to add a Menu item ...
// Get a UIObject object that represents Visio built-in menus.
Visio::IVUIObjectPtr vsoUIObject = app->GetBuiltInMenus();
// Get the MenuSets collection.
Visio::IVMenuSetsPtr vsoMenuSets = vsoUIObject->GetMenuSets();
// Get the drawing window menu set.
Visio::IVMenuSetPtr vsoMenuSet =
vsoMenuSets->GetItemAtID(visUIObjSetDrawing);
// Get the Menus collection.
Visio::IVMenusPtr vsoMenus = vsoMenuSet->GetMenus();
// Add a new menu before the Window menu.
Visio::IVMenuPtr vsoMenu = vsoMenus->AddAt(7);
vsoMenu->PutCaption(_bstr_t("MyNewMenu"));
// Get the MenuItems collection.
Visio::IVMenuItemsPtr vsoMenuItems = vsoMenu->GetMenuItems();
// Add a menu item to the new menu.
Visio::IVMenuItemPtr vsoMenuItem = vsoMenuItems->Add();
// Set the Caption property for the new menu item.
vsoMenuItem->PutCaption(_bstr_t("&MyNewMenuItem"));
// Tell Visio to use the new UI when the document is active.
Visio::IVDocumentsPtr vsoDocuments = app->GetDocuments();
Visio::IVDocumentPtr vsoDocument =
vsoDocuments->GetItem(_variant_t(1));
vsoDocument->SetCustomMenus(vsoUIObject);
Regards,
Mark