VCD Context Menu Suppression

T

Tosh

I've spent all day trying to suppress the context menu that the Visio Drawing
Control pops up when you right-click on a shape. I've iterated through the
BuiltInMenus, menuSets, and MenuItems and deleted them all, but the context
menu still appears.

I handled the mouse-up event from the drawing control and set
e.cancelDefault = true. No more context menu, but I also can't use the
pointer tool to select shapes or edit the text, so this isn't a viable
solution.

From some of the other posts it looks like some of you have been able to do
this, but I haven't been able to figure it out.

What am I missing?
 
J

JuneTheSecond

Hi,

All of the context menus pop up or some of or one of ?
How did you do ?
I am afraid that some of basic menus cannot delete,
since I could not delete the menu bar on the regular
Visio window with VBA.
 
T

Tosh

There are two context menus in particular I'm trying to suppress. One comes
from the right-click on the drawing surface (the page?), with no shapes
selected. It has the following options:
Cut
Copy Drawing
Paste
----
Format >
Data >
----
Help

The other is comes from the right-click of a shape such as a rectangle,
text, or an image. These are all displaying the same context menu:
Cut
Copy
Paste
----
Format >
Data >
Shape >
----
Help

Here's what I've run to attempt to delete the menus, but it hasn't had any
impact on these context menus. Looking at what comes out through the
Debug.Print statements, I don't see the set of menu options that show up in
the context menu. I'm now thinking the Built-In menus are not the ones I
need to address, and there are more menus in some other object.

But what would that object be?

Here's the code:

private void button7_Click(object sender, EventArgs e)
{
MenuSet menuSet = null;
Menus menus = null;
Microsoft.Office.Interop.Visio.Menu menu = null;
Microsoft.Office.Interop.Visio.MenuItem menuItem = null;

System.Diagnostics.Debug.Print(_application.BuiltInMenus.Name);

for (int idx = 0; idx <
_application.BuiltInMenus.MenuSets.Count; idx++)
{
menuSet = _application.BuiltInMenus.MenuSets[idx];
System.Diagnostics.Debug.Print(idx.ToString() + " " +
menuSet.Caption);

for (int menuIDX = 0; menuIDX < menuSet.Menus.Count;
menuIDX++)
{
menu = menuSet.Menus[menuIDX];
System.Diagnostics.Debug.Print(" " + menuIDX.ToString()
+ " " + menu.Caption);

for (int menuItemIdx = 0; menuItemIdx <
menu.MenuItems.Count; menuItemIdx++)
{
menuItem = menu.MenuItems[menuItemIdx];
System.Diagnostics.Debug.Print(" " +
menuItemIdx.ToString() + " " + menuItem.Caption);
menuItem.Delete();
}

menu.Delete();
}
menuSet.Delete();
}
}
 
V

vojo

I did not see any visible settings set
Here is what I do....


'// Now go 'full screen' by turning everything off:
'stencil window off
Visio.Application.DoCmd (1669)

Visio.Application.ShowToolbar = False
Visio.Application.ShowStatusBar = False
Visio.ActiveWindow.ShowPageTabs = False
Visio.ActiveWindow.ShowRulers = False
Visio.ActiveWindow.ShowGrid = False



'// Now go back to the way it was:
Visio.Application.ShowToolbar = True
Visio.Application.ShowStatusBar = True
Visio.ActiveWindow.ShowPageTabs = True
Visio.ActiveWindow.ShowRulers = True
Visio.ActiveWindow.ShowGrid = True
'stencil window on
Visio.Application.DoCmd (1669)
 
T

Tosh

It turned out to be very simple, once someone pointed out the e.button
property in the MouseUp event.

/// <summary>
/// Suppress Visio context menus by cancelling default handling of a
right-mouse Up.
/// Allows all other mouse-up actions to occur - which is important,
because that has Select-object, enter text-edit mode, more...
/// </summary>
private void drawingControl_MouseUpEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseUpEvent e)
{
if (e.button == (int)VisKeyButtonFlags.visMouseRight)
{
e.cancelDefault = true;
}
}
 

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