Visio Shape Context Menu

E

Evgchech

Hello!
I am trying to add customized entries to Shape and Page context menus.
I have downloaded example how to perform this task for application menu it
works just fine. I can not figure it out how to acquire handle to shape or
page context menu.

Here is an code example

Microsoft.Office.Core.CommandBars applicationCommandBars;
Microsoft.Office.Core.CommandBar menuBar;
Microsoft.Office.Core.CommandBarPopup menuPopup;
// Get the CommandBars object from Visio.
applicationCommandBars = (Microsoft.Office.Core.CommandBars)
visApplication.CommandBars;
// Get the active menu bar from the CommandBars object.
menuBar = applicationCommandBars.ActiveMenuBar;
//Add a pop-up menu to the end of the active menu bar.
menuPopup = (Microsoft.Office.Core.CommandBarPopup)
menuBar.Controls.Add(
Microsoft.Office.Core.MsoControlType.msoControlPopup,
1, "", 10, true);
menuPopup.Caption = "C&ustom";


The first and the second lines acquires handle to application menu bar
I need to replace those lines so i could address shape or page context menus
in the same way

Best Regards
 
J

junethesecond

Context property exists, but it is the property of CommandBar. So, you
would use add method to CommandBars. Farther, kind of context is limited
to the items listed in enumerated constants VisUIObjSets in visio help,
drawing, shapesheet,etc.
 
M

Markus Breugst

Hi Evgchech,

you don't need any CommandBars or other UI stuff in order to extend the
context menus of shapes and pages.

Instead, just use the ShapeSheet. To add a new context menu item, add a new
row to the "Custom Properties" table of the ShapeSheet. You can do this by
hand or by using automation.

You can find several newsgroup threads with example code, like this one:
http://groups.google.de/groups?hl=d...%23IwnEEHA.1032%40TK2MSFTNGP09.phx.gbl&rnum=1

Hope this helps.

Best regards,
Markus
 
E

Evgchech

Hello Markus!!!
First of all thanks a lot for your effort.
This solution is not exactly what I am looking for, because
I need the context menu to contain sub menu (menu items).
By adding new action to ShapeSheet I can add only "one level" menu
For now I am using your solution, but if you know any another way to address
context menu in a way it allows to create sub menus , I will be more than
grateful.

In addition I have another question with your permission.
By adding new action there is an option to specify ButtonFace(icon) for the
menu.
The problem is that only build in icon IDs allowed.
How do I add a new icon and attach ID for it so it can be addressed as the
rest
of the build in icons in Visio.

Best Regards
Yevgeny Chechelnitsky
 
J

junethesecond

Context property to custom CommandBar is available. But the modes are
limited to the drawing, shapesheet, and so on, as it is listed in
ennumurated constants, visUiObjSets.
How would you like to use UserForm which is designed as you like and
displayed in mode-less when a shape is dropped on the drawing?
 
J

junethesecond

Picture property may be available.
Help is available at Excel's help, because CommandBarControl is not an
object of Visio, but of Office.
By the way, Visio has its own UIObject,
where "ico" file can be used to IconFileName property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top