Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Customizing Visio menu?

10 views
Skip to first unread message

Nikolay Belyh

unread,
Jul 28, 2008, 8:40:22 AM7/28/08
to
I've got a strange problem with Visio menu customization.
IF there already is a custom visio ui when I try to install my ui,
then some of my menu items do not
appear.nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

Nikolay Belyh

unread,
Jul 28, 2008, 8:51:28 AM7/28/08
to
Sorry, the previous message seems to get cut. Please ignore it.

Here is my problem.


IF there already is a custom visio ui when I try to install my ui,
then some of my menu items do not appear.

Namelly, all items that are being added under my own (top-level) menu
are added normally, but all items that are added under Visio's
"native" menus are for some reason not made visible in Visio UI. This
happens only when I install my menu items into existing custom menu
(added either by user or by other add-in).

All menus are added using "native" ui customization interface, i.e.
"command bars" interfrace is not used.

Application.CustomMenus.UpdateUI is called.

Any help?
Kind regards, Nikolay.

Paul Herber

unread,
Jul 28, 2008, 11:51:10 AM7/28/08
to

There are a few (3 that I know of) addons that don't follow the rules
and prevent other addons from adding items to the main menu.
There is nothing your code can do to get around this.


--
Regards, Paul Herber, Sandrila Ltd.
http://www.sdl.sandrila.co.uk/ SDL/MSC//URN/UML2 for Visio

Nikolay Belyh

unread,
Jul 28, 2008, 1:17:07 PM7/28/08
to
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.

John Goldsmith (Visio MVP)

unread,
Jul 28, 2008, 2:51:55 PM7/28/08
to
Hello Nikolay,

I think Paul's right although my experience was that I wasn't able to pin it
down to a particular add-in or 'on' (I think I'd disabled pretty much
everything, but still no luck).

Not much help I'm afraid, but I can confirm the behaviour you're seeing as
these are exactly the symptoms I came across a year ago or so.

Are you building a document specific solution or might the CommandBars model
help instead?

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk

"Nikolay Belyh" <nbe...@gmail.com> wrote in message
news:1bae4cf7-e331-458a...@34g2000hsf.googlegroups.com...

Paul Herber

unread,
Jul 28, 2008, 5:20:20 PM7/28/08
to

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[i] +
sCRLF
else
dlgTxt := dlgTxt + messages.Strings[i] + 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;

--
Regards, Paul Herber, Sandrila Ltd.

Visio Utilities http://www.visio-utilities.sandrila.co.uk/

Nikolay Belyh

unread,
Jul 29, 2008, 4:15:40 AM7/29/08
to
Paul, many thanks, I'll try that.

Well, actually I knew that issue with "menu not appearing in UI" can
be sometimes cured by changing ConfigChangeID (or how do you call
that) registry key, but I'm definitely having some other issue. I
mean, my addon runs, adds all menus, and I can enumerate all my items
using Visio API. According to API, all items are in place, visible and
enabled. I mean, if I iterate through menu items, all items I have
added are presented. BUT only items that were added under MY top-level
menu are actually visible. "UpdateUI" does not help. The items added
under visio's native menus are just not visible. That is the issue I'm
fighting against..

And the above happens ONLY if the visio menu has been pre-customized
by other addin. I.e. this happens if I do menu customization from
(already customized by another addon) Application.CustomMenus.

Kind regards, Nikolay.

Paul Herber

unread,
Jul 29, 2008, 4:51:53 AM7/29/08
to

Do you want to post your code? Or email it to me?


--
Regards, Paul Herber, Sandrila Ltd

http://www.electronics-packages.sandrila.co.uk/

Nikolay Belyh

unread,
Jul 29, 2008, 12:50:14 PM7/29/08
to
It seems that I have found out the conditions under which it does not
work (is it a bug??). You cannot add menu items to the LAST visio
menu. That is, you can't add items to "Help" menu. You can add items
to any menu but the last one. Also you cannot add items to a "context"
custom menu (probably for the same reason, since it has only one item
- i.e. the "last" one). I mean, I can't add items to
"visUIObjSetCntx_DrawObjSel" menu as well. All of the above is true if
the menu has been pre-customized, i.e. if I start from the custom
menu.

----- the sample code -----

Set cm = Application.CustomMenus
Set mnus = cm.MenuSets.ItemAtID(2).Menus
Set mi = mnus(0).MenuItems.Add
mi.Caption = "This works"
Application.CustomMenus = cm
Application.CustomMenus.UpdateUI

Set cm = Application.CustomMenus
Set mnus = cm.MenuSets.ItemAtID(2).Menus
Set mi = mnus(mnus.Count - 2).MenuItems.Add
mi.Caption = "This also works"
Application.CustomMenus = cm
Application.CustomMenus.UpdateUI

Set cm = Application.CustomMenus
Set mnus = cm.MenuSets.ItemAtID(2).Menus
Set mi = mnus(mnus.Count - 1).MenuItems.Add
mi.Caption = "This does not work"
Application.CustomMenus = cm
Application.CustomMenus.UpdateUI

------

Any help?
Kind regards, Nikolay

John Goldsmith (Visio MVP)

unread,
Jul 29, 2008, 2:51:22 PM7/29/08
to
Nickolay,

That isn't line with my tests. Toools and Data menus, for example, also
displayed the same problem. I agree about the context menu though.

Best regards

John


"Nikolay Belyh" <nbe...@gmail.com> wrote in message

news:1b45202a-13cf-4119...@26g2000hsk.googlegroups.com...

Paul Herber

unread,
Jul 31, 2008, 2:37:43 PM7/31/08
to
On Tue, 29 Jul 2008 09:50:14 -0700 (PDT), Nikolay Belyh
<nbe...@gmail.com> wrote:

>It seems that I have found out the conditions under which it does not
>work (is it a bug??). You cannot add menu items to the LAST visio
>menu. That is, you can't add items to "Help" menu.

http://www.sandrila.co.uk/addedtohelpmenu.png


--
Regards, Paul Herber, Sandrila Ltd.
DFD for Visio http://www.gane-sarson.sandrila.co.uk/

Nikolay Belyh

unread,
Aug 3, 2008, 9:00:23 PM8/3/08
to

> http://www.sandrila.co.uk/addedtohelpmenu.png

You can add to help menu normally; I know that:

http://pix.academ.org/img/2008/08/04/55ba99d308a6c9b38a9af90e5439c759

All of the above weird stuff happens only if you try installing your
menu into menu that has been already pre-cusotmized by another
"external" addon (and that is not UML or Database addon, just third-
party addon). I.e. if the menu has been already pre-customized by
addon that is not located in your own DLL (I belive).

Kind regards, Nikoay.

Paul Herber

unread,
Aug 4, 2008, 8:39:58 PM8/4/08
to

I shall try that tomorrow.
So, if you write an addon that adds a menu to the File menu, then try
my http://www.visio-recent-stencils.sandrila.co.uk/ which also
modifies the File menu. Would that prove the effect?


--
Regards, Paul Herber, Sandrila Ltd.

Electrical for Visio http://www.electrical.sandrila.co.uk/

Barb Way

unread,
Aug 11, 2008, 12:31:09 PM8/11/08
to
Some add-ins (both Visio built-in and third party) use the Built-In menus
and toolbars by default, rather than grabbing the current context when they
are opened. This means that your customizations are not retained while the
solution or add-in is open. UML and Database modeling are known to have
this problem, and third party tools like the Adobe PDFMaker also exhibits
the problem. There's no way to change this behavior, and it occurs in all
versions of Visio.


Barb Way
Product Support - Visio
Microsoft Corporation
[This posting is provided "As Is" with no warranties, and confers no
rights.]
--------------------

Nikolay Belyh

unread,
Aug 18, 2008, 8:27:40 AM8/18/08
to
Barb, thank you for response.

Unfortunately I don't think this is the case. The third-party addon
I'm dealing with seems to behave properly (unlike UML). Actually I was
able to reproduce the issue I'm fighting with (last menu cannot be
changed using "UIObject" model) using pure VBA only.NB: I was able to
change that last menu item using "CommandBars" technology.
Unfortunately my current project customization is bound to UIObjects,
so moving to CommandBars does not sound any fun. Actually, the real
issue is not the last menu item (it's nothing compared to world-wide
revolution :), the issue I can't bear with is that I'm unable to
change the context (right-click) menu using UIObjects under these
conditions (i.e. when two addins are installed and both of them have
done some customization to application-level custom menu). I guess
this might be the same problem, since for context menu there is only
one item in the menu (and thus it is the last one).

So here are the steps to reproduce the issue (I'm working with Visio
2007 Pro, Windows XP SP3)

1. Start Visio.
2. Customize Visio menu manually. E.g. add extra menu item. This
imitates the activity of that third-party-addon. Like this:
http://nbelyh.googlepages.com/visiomenu1.png
3. Run the code below to customize the menu. This time it will work
(!)
4. Close Visio (this will save custom ui)
5. Start Visio again.
6. Run the same code to customize menu once again. This time it will
NOT work for the last menu item (!!!). And this is the problem...

-----

Sub Demo()

Set cm = Application.CustomMenus
Set mnus = cm.MenuSets.ItemAtID(visUIObjSetDrawing).Menus

Set mi1 = mnus.Item(mnus.Count - 2).MenuItems.Add
mi1.Caption = "WORKS ALWAYS"

Set mi2 = mnus.Item(mnus.Count - 1).MenuItems.Add
mi2.Caption = "THE PROBLEM"

cm.UpdateUI

End Sub

-----

The empty drawing that contains that code can be found here:
http://nbelyh.googlepages.com/visiomenu1.vsd

Any help?

Kind regards, Nikolay.

0 new messages