D
David Thielen
Hi;
This is happening on my computer only (thank god). But I want to
figure out what is going on.
1) This is code that has been running for months without being
touched. And it runs fine on every other computer.
2) This occured after I installed the new shim wizard and got the
shims working. However it occurs if I run with or without the shim. So
I don't think it's a shim issue.
3) If I reset the menu toolbar, exit Word, and then start Word - it
builds my menu correctly. No problems.
4) When I look in the debugger at the end of my menu initialization,
the menu I created is correct.
5) I store my copy of the menu objects in global memory so it has not
been thrown away by the garbage collector.
But... If the menu already exists and my code deletes it and builds it
new, it randomly does one of the following thinks:
a) My menu is in the top menu bar for Word - but has nothing in it.
b) My menu is in the top menu bar and it's contents are the contents
of one of the pop-up menus in my menu. In other words it would be like
the Tools menu's content is just the content of Tools | Language or
Tools | Letters and Mailings. I have 4 pop-up menus in my main menu
and it is randomly any one of these 4 pop-up's content set as the main
menu content.
The fact that this is code I haven't touched for awhile AND the fact
that it is randomly different (or no) children of a single
msoControlPopup in my menu makes me think the problem is in Word.
Any ideas?
thanks - dave
My code (I have a class that has the values used to create the menu
and it stores the created menu object):
CommandBar MainMenuBar = GetCommandBar("Menu Bar");
mainMenu[0].OfficeMenu =
MainMenuBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, before, false);
mainMenu[0].OfficeMenu.Caption = mainMenu[0].Caption;
mainMenu[0].OfficeMenu.TooltipText = mainMenu[0].Tooltip;
mainMenu[0].OfficeMenu.Tag = mainMenu[0].Tag;
// build the menu - main and sub-menus
BuildMenu(mainMenu[0]);
private static void BuildMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{
if (menuOn.Children != null)
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlPopup,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;
BuildMenu(menuOn);
}
else
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlButton,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.Visible = true;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;
if (menuOn.Handler != null)
((CommandBarButton)menuOn.OfficeMenu).Click += menuOn.Handler;
}
}
}
david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm
This is happening on my computer only (thank god). But I want to
figure out what is going on.
1) This is code that has been running for months without being
touched. And it runs fine on every other computer.
2) This occured after I installed the new shim wizard and got the
shims working. However it occurs if I run with or without the shim. So
I don't think it's a shim issue.
3) If I reset the menu toolbar, exit Word, and then start Word - it
builds my menu correctly. No problems.
4) When I look in the debugger at the end of my menu initialization,
the menu I created is correct.
5) I store my copy of the menu objects in global memory so it has not
been thrown away by the garbage collector.
But... If the menu already exists and my code deletes it and builds it
new, it randomly does one of the following thinks:
a) My menu is in the top menu bar for Word - but has nothing in it.
b) My menu is in the top menu bar and it's contents are the contents
of one of the pop-up menus in my menu. In other words it would be like
the Tools menu's content is just the content of Tools | Language or
Tools | Letters and Mailings. I have 4 pop-up menus in my main menu
and it is randomly any one of these 4 pop-up's content set as the main
menu content.
The fact that this is code I haven't touched for awhile AND the fact
that it is randomly different (or no) children of a single
msoControlPopup in my menu makes me think the problem is in Word.
Any ideas?
thanks - dave
My code (I have a class that has the values used to create the menu
and it stores the created menu object):
CommandBar MainMenuBar = GetCommandBar("Menu Bar");
mainMenu[0].OfficeMenu =
MainMenuBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, before, false);
mainMenu[0].OfficeMenu.Caption = mainMenu[0].Caption;
mainMenu[0].OfficeMenu.TooltipText = mainMenu[0].Tooltip;
mainMenu[0].OfficeMenu.Tag = mainMenu[0].Tag;
// build the menu - main and sub-menus
BuildMenu(mainMenu[0]);
private static void BuildMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{
if (menuOn.Children != null)
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlPopup,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;
BuildMenu(menuOn);
}
else
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlButton,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.Visible = true;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;
if (menuOn.Handler != null)
((CommandBarButton)menuOn.OfficeMenu).Click += menuOn.Handler;
}
}
}
david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm