Right-Mouse Customization Using CommandBars

M

Mordechai

I'd like to create customized cascading right-mouse context menu(s) in
Visio. I can't use the Shapesheet's Actions section since that doesn't
support cascading pop-ups. I've looked through the UIObject documentation
(including Chapter 22 of DMVS) but it seems to me that UIObjects only
pertain to Menus and Toolbars, not to pop-up context menus - (if I'm missing
something please point me in the right direction).

In any event, this should be very straightforward with CommandBars. If this
were Excel I'd simply get the appropriate pop-up CommandBar with 'set cbBar
= Application.CommandBars("cell")' and then proceed to customize cbBar via
the object model. So I assumed that all I needed was the "name" of the
pop-up CommandBar and I'd be home free. No good - I've dumped all the
CommandBars and can't seem to find any that correspond to any pop-up menus.
Here's the code I used to dump all the CommandBars.

Public Sub dumpbars()
Dim cmdBar As CommandBar, cbCtl As CommandBarControl
For Each cmdBar In Application.CommandBars
Debug.Print "New Bar: " & cmdBar.Name & ", context is ";
cmdBar.Context
For Each cbCtl In cmdBar.Controls
Debug.Print "..." & cbCtl.Caption
Next
Debug.Print
Next
End Sub

Any suggestions. The environment is Visio 2003.

Thanks
 
M

Mark Nelson [MS]

M

Mordechai

Mark:

I did check out chapter 22. It seems to me that the menus
that these refer to are the top-level menus on the
applicaiton window. Unless I'm missing something I don't
see how this helps you get and manipulate the pop-up
right-mouse context menu.

-- Mordechai
 
M

Mark Nelson [MS]

Treat it like any other menu. To work on a menu, you have to supply a
context. Supply the context I posted below.
 
M

Mordechai

I tried it and it's working. Thanks a lot.

I think my mental block here was the fact that you have
to copy the UI and then apply it to something (such as
ThisDocument) before it becomes active. This is somewhat
different than the CommandBars approach in which menu
changes are immediatly active.

Upon reflection, I prefer the approach in Visio since
that way I don't have to worry if someone opens up
another document while my solution is open.

Is there an easy way to pass a handle to the selected
shape to the action so that I know who called me?

-- Mordechai
 
M

Mark Nelson [MS]

Generally, commands work on the current drawing window selection. Ask Visio
for the Selection property of the current Window.
 

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