I know 2 of them; these are UML addon, Database addon.
But actually this is not the thing I am talking about.
My issue is that when I add menu item under MY menu, it function
properly.
But when I add item under VISIO's menu, it is just not shown..
And the above happens only if the menu has been pre-customized by
another addon.
If I take original visio menu (builtin menu) and applying the
customization to that menu,
everything works perfectly.
Odd, I've got at least 3 of my own add-ons all running at the same
time, 2 add their own top-level menu and one adds itself to the File
menu.
And they all work in conjunction with the better behaved add-ons,
Plan, Org-Chart etc.
I have had reports stating that the menus don't appear, but then
suddenly start working 2 days later and the continue to do so. I put
that down to the add-on cache not being updated but have no further
evidence of that.
However, I do a few tricks when creating menus, I've included a
complete procedure here (in Delphi but that shouldn't matter - I do
wish Graham Wideman would update his Delphi Visio framework) for
adding a menu with submenu to the File menu.
procedure add_menus(bEnableEvents: boolean);
var
UIObj: Visio_TLB.UIObject;
menusObj: Visio_TLB.Menus;
menuObj: Visio_TLB.Menu;
menuItemObj: Visio_TLB.MenuItem;
visioMenuItemObj: Visio_TLB.MenuItem;
ready: boolean;
i: smallint;
messages: TStringList;
msgDlg: TSimpleForm;
dlgTxt: string;
begin
messages := TStringList.Create;
//messages.Add('Started setting menus.');
try
//MessageDlg('Getting UIObj', mtInformation, [mbOk], 0); // debug
// wait for any startup dialogs to finish
ready := false;
while (ready = false) do
begin
try
if Visio_Controller.Application.BuiltInMenus <> nil then
ready := true;
Forms.Application.ProcessMessages;
except;
end;
end;
sleep(random(3000));
try
UIObj := Visio_Controller.Application.CustomMenus;
if UIObj = nil then
UIObj := Visio_Controller.Application.BuiltInMenus;
except
UIObj := Visio_Controller.Application.BuiltInMenus;
end;
try
Visio_Controller.Application.SetCustomMenus(UIObj);
//MessageDlg('Getting menusObj', mtInformation, [mbOk], 0); //
debug
menusObj := UIObj.MenuSets.ItemAtID[visUIObjSetDrawing].Menus;
//MessageDlg('Getting menuObj', mtInformation, [mbOk], 0); //
debug
menuObj := menusObj.Item[0];
i := menuObj.MenuItems.Count - 1;
if menuObj.MenuItems.Item[i-1].Caption = scMenuRecentStencils then
begin
messages.Free;
exit; // already exists
end;
visioMenuItemObj := menuObj.MenuItems.AddAt(i);
visioMenuItemObj.Caption := scMenuRecentStencils;
Visio_Controller.Application.SetCustomMenus(UIObj);
Visio_Controller.Application.CustomMenus.UpdateUI;
except;
end;
//MessageDlg('Getting menuItemObj', mtInformation, [mbOk], 0); //
debug
//MessageDlg('Setting caption', mtInformation, [mbOk], 0); // debug
try
// Most recently used Stencils menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuMostRecentStencils;
menuItemObj.AddOnName := scMenuMostRecentStencilsVRSAddOn;
menuItemObj.ActionText := scMenuMostRecentStencils;
menuItemObj.MiniHelp := scMenuMostRecentStencils;
{$IFDEF bMyTestingMode}
// remove registration menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuRemoveRegistration;
menuItemObj.AddOnName := scMenuRemoveRegistrationVRSAddOn;
menuItemObj.ActionText := scMenuRemoveRegistration;
menuItemObj.MiniHelp := scMenuRemoveRegistration;
{$ENDIF}
// check for updates menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuVRSCheckForUpdates;
menuItemObj.AddOnName := scMenuCheckUpdateVRSAddOn;
menuItemObj.ActionText := scMenuVRSCheckForUpdates;
menuItemObj.MiniHelp := scMenuVRSCheckForUpdates;
// enter registration key menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuEnterRegistrationKey;
menuItemObj.AddOnName := scMenuEnterRegistrationKeyVRSAddOn;
menuItemObj.ActionText := scMenuEnterRegistrationKey;
menuItemObj.MiniHelp := scMenuEnterRegistrationKey;
// help menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuVSUHelp;
menuItemObj.AddOnName := scMenuHelpVRSAddOn;
menuItemObj.ActionText := scMenuVSUHelp;
menuItemObj.MiniHelp := scMenuVSUHelp;
// about menu
menuItemObj := visioMenuItemObj.MenuItems.Add;
menuItemObj.Caption := scMenuVRSAbout;
menuItemObj.AddOnName := scMenuVSUAboutVRSAddOn;
menuItemObj.ActionText := scMenuVRSAbout;
menuItemObj.MiniHelp := scMenuVRSAbout;
Visio_Controller.Application.SetCustomMenus(UIObj);
Visio_Controller.Application.CustomMenus.UpdateUI;
except;
end;
//messages.Add('Finished setting menus.');
except
//messages.Add(scExceptionInSettingMenus);
end;
dlgTxt := '';
for i := 0 to messages.Count-1 do
begin
if messages.count > 1 then
dlgTxt := dlgTxt + fStr(i+1) + '. ' + messages.Strings
+
sCRLF
else
dlgTxt := dlgTxt + messages.Strings + sCRLF;
end;
waitingForForm := false;
if dlgTxt <> '' then
begin
waitingForForm := true;
try
msgDlg := TSimpleForm.Create(Forms.Application);
msgDlg.SetText(dlgTxt);
msgDlg.Show;
except;
end;
end;
messages.Free;
// wait for dialog to be closed
while (waitingForForm = true) do
begin
try
Forms.Application.ProcessMessages;
except;
end;
end;
if bEnableEvents then
enableEvents();
end;