Working with Visio 2003 Page & Shape context (popup) menus in C# .

M

MikeBTP

We are using Visio 2003 as a drawing control in a C# project and are able to
manipulate or use various Visio built-in menus but cannot change the context
(right-click popup) menu for a drawing page or shape. How do we access this
menu and remove some of its menu items and add our own menu items. Not able
to determine what menu it is and when we can access it (before displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
J

John Goldsmith

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk
 
M

MikeBTP

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike
 
D

dinesh

Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh
 
M

MikeBTP

Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike
 
D

dinesh

Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



MikeBTP said:
Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


dinesh said:
Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh
 
M

MikeBTP

You will need to add a ContextMenuStrip to the form and in the drawing's
MouseUp event you add the code to open this menu something like:
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
m_contextMenuStrip.Show(control, clientPos);


dinesh said:
Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



MikeBTP said:
Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


dinesh said:
Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh




:

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike

:

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk

We are using Visio 2003 as a drawing control in a C# project and are able
to
manipulate or use various Visio built-in menus but cannot change the
context
(right-click popup) menu for a drawing page or shape. How do we access
this
menu and remove some of its menu items and add our own menu items. Not
able
to determine what menu it is and when we can access it (before
displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
D

dinesh

hi

can u provide me full code , still i am not able to display the menu,

my problem is i have to add a menuitem on the menu which is displayed when
the user right clicks on the shape which he has drawn on the visio sheets.

i would be highly thankful to u , if u could provide me the whole code or
mail me.
(e-mail address removed)


thanks

dinesh



MikeBTP said:
You will need to add a ContextMenuStrip to the form and in the drawing's
MouseUp event you add the code to open this menu something like:
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
m_contextMenuStrip.Show(control, clientPos);


dinesh said:
Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



MikeBTP said:
Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


:

Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh




:

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike

:

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk

We are using Visio 2003 as a drawing control in a C# project and are able
to
manipulate or use various Visio built-in menus but cannot change the
context
(right-click popup) menu for a drawing page or shape. How do we access
this
menu and remove some of its menu items and add our own menu items. Not
able
to determine what menu it is and when we can access it (before
displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
M

MikeBTP

That is all the code. If you have a form in C# with Visio 2003 imbedded in
that form and add a ContextMenuStrip to the form that's all the code you need.

If this is not how you're using Visio then what you need will probably be
different.

Mike

dinesh said:
hi

can u provide me full code , still i am not able to display the menu,

my problem is i have to add a menuitem on the menu which is displayed when
the user right clicks on the shape which he has drawn on the visio sheets.

i would be highly thankful to u , if u could provide me the whole code or
mail me.
(e-mail address removed)


thanks

dinesh



MikeBTP said:
You will need to add a ContextMenuStrip to the form and in the drawing's
MouseUp event you add the code to open this menu something like:
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
m_contextMenuStrip.Show(control, clientPos);


dinesh said:
Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



:

Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


:

Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh




:

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike

:

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk

We are using Visio 2003 as a drawing control in a C# project and are able
to
manipulate or use various Visio built-in menus but cannot change the
context
(right-click popup) menu for a drawing page or shape. How do we access
this
menu and remove some of its menu items and add our own menu items. Not
able
to determine what menu it is and when we can access it (before
displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
D

dinesh

hi mike

i'm working in .Net Framework 3.0 thatswhy i think code given by u is not
executing. can u help me out
i 'm using windows form Integration on that we r embedding visio control

thanks

dinesh


MikeBTP said:
That is all the code. If you have a form in C# with Visio 2003 imbedded in
that form and add a ContextMenuStrip to the form that's all the code you need.

If this is not how you're using Visio then what you need will probably be
different.

Mike

dinesh said:
hi

can u provide me full code , still i am not able to display the menu,

my problem is i have to add a menuitem on the menu which is displayed when
the user right clicks on the shape which he has drawn on the visio sheets.

i would be highly thankful to u , if u could provide me the whole code or
mail me.
(e-mail address removed)


thanks

dinesh



MikeBTP said:
You will need to add a ContextMenuStrip to the form and in the drawing's
MouseUp event you add the code to open this menu something like:
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
m_contextMenuStrip.Show(control, clientPos);


:

Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



:

Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


:

Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh




:

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike

:

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk

We are using Visio 2003 as a drawing control in a C# project and are able
to
manipulate or use various Visio built-in menus but cannot change the
context
(right-click popup) menu for a drawing page or shape. How do we access
this
menu and remove some of its menu items and add our own menu items. Not
able
to determine what menu it is and when we can access it (before
displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
M

MikeBTP

I'm not sure how much more help I can be. Framework 3.0 shouldn't make a
difference because I think it is an extension to 2.0.
The Visio SDK may be able to answer some of your questions. Particularly the
section about Visio Drawing Control Concepts.
http://msdn2.microsoft.com/en-us/library/aa173161(office.11).aspx

dinesh said:
hi mike

i'm working in .Net Framework 3.0 thatswhy i think code given by u is not
executing. can u help me out
i 'm using windows form Integration on that we r embedding visio control

thanks

dinesh


MikeBTP said:
That is all the code. If you have a form in C# with Visio 2003 imbedded in
that form and add a ContextMenuStrip to the form that's all the code you need.

If this is not how you're using Visio then what you need will probably be
different.

Mike

dinesh said:
hi

can u provide me full code , still i am not able to display the menu,

my problem is i have to add a menuitem on the menu which is displayed when
the user right clicks on the shape which he has drawn on the visio sheets.

i would be highly thankful to u , if u could provide me the whole code or
mail me.
(e-mail address removed)


thanks

dinesh



:

You will need to add a ContextMenuStrip to the form and in the drawing's
MouseUp event you add the code to open this menu something like:
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
m_contextMenuStrip.Show(control, clientPos);


:

Hi Mike

thanks for the reply , i was able to disable the right click menu with your
code,
but i was unable to add the contextmenustrip to the visio can u help me out
with this, if possible a piece of code.

actually i want to add an item to that menu or we can create a new menu in
place.

thanks

dinesh



:

Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup context
menu as I would have liked to so I disabled it using code below and added a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars = office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it and
popup the context menu. None of the Visio events I tried was able to give me
this info.

Regards,

Mike


:

Hi Mike and John
even i Have the same problem as mike has but was not able to figure out it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of code.

thanks

dinesh




:

Hi John,

Thank you so much for the info. This should help a lot. If I have any other
questions after digesting this I'll ask.

Any info you give me is always useful even if I'm already aware of
something. It might, as in the case of the Actions in shapesheet, give me a
reason to look further into something that I may have overlooked.

Thanks again,
Mike

:

Hello Mike,

You can delete menus/items as you wish from the CommandBars collection or
the UIObject (CommandBars is the prefered method these days).

Take a look at this link, which describes how to carry out the operation:

http://msdn2.microsoft.com/en-us/library/aa201791(office.10).aspx

Bear in mind also (apologies if I'm not telling you something new) that
shapes can also contain right-click menu items within the Actions shapesheet
section.

Best regards

John


John Goldsmith
www.visualSignals.co.uk

We are using Visio 2003 as a drawing control in a C# project and are able
to
manipulate or use various Visio built-in menus but cannot change the
context
(right-click popup) menu for a drawing page or shape. How do we access
this
menu and remove some of its menu items and add our own menu items. Not
able
to determine what menu it is and when we can access it (before
displaying).
Any VBA sample code would also be helpful.

Thanks for any help,
Mike
 
G

Gordon Humphrey

Mike -

Forgive me if you get two postings of this - I dont know if you ever got my
other posting ...

I added this line in my Initialize() function ..

this.VisioDrawingControl.MouseUpEvent +=new
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseUpEventHandler(VisioDrawingControl_MouseUpEvent);

the the function:


protected void VisioDrawingControl_MouseUpEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseUpEvent e)
{
Control control = (Control)sender;
Point clientPos = control.PointToClient(Cursor.Position);
contextMenuStrip1.Show(control, clientPos);
}

My new context menu is never shown and I cannot prevent the native (default)
Visio context menu from being shown? I want to DISABLE to menu for shapes
and the drawing workspace / "surface". How is this accomplished? I am at a
loss ...

Gordon Humphrey




MikeBTP said:
Hi Dinesh,

I was not able to work with the Built-in Menus of Visio 2003 but did use
the
CommandBars object from office (COM reference to MS Office 11.0 object
lib---mso.dll). Unfortunately, I was not able to manipulate the popup
context
menu as I would have liked to so I disabled it using code below and added
a
ContextMenuStrip in C#.

office.CommandBars cBars;
cBars =
office.CommandBars)this.m_drawing.Document.Application.CommandBars;
cBars["Drawing Object Selected"].Enabled = false;

This still left me with an issue of what has the focus (a shape or the
sheet) when a user right-clicks on an object to simultaneously select it
and
popup the context menu. None of the Visio events I tried was able to give
me
this info.

Regards,

Mike


dinesh said:
Hi Mike and John
even i Have the same problem as mike has but was not able to figure out
it,
can u guys help me out with this, i would be highly appreciate your help.
if u could let me know the way to proceed and if possible a piece of
code.

thanks

dinesh
 

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