How do I ... RMB menu

D

David Thielen

Hi;

How can I set the RMB menu on a right mouse button click? I know that there
is an event for the RMB - but how do I then set the menu?
 
P

Peter Huang [MSFT]

Hi

I think Word has its own Context Menu, when you click on different place in
the winword application.
If you wants to show your own, I think you may try to delete/hide the
existing ones and add the new ones you wants to show.
e.g. the Text CommandBar is the Context Menu when you right click on the
text area of the word document.

Sub Test()
Dim cb As CommandBar
For Each cb In Application.CommandBars
Debug.Print cb.Name
If cb.Name = "Text" Then
Dim cbb As CommandBarControl
For Each cbb In cb.Controls
Debug.Print " " & cbb.Caption
Next
End If
Next
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hello;

Isn't there a way I can just pop-up my own menu and not have the Word one go
up at all?
 
P

Peter Huang [MSFT]

Hi

Although, we can handle the WindowBeforeRightClick event and set Cancel
=true to cancel the right click to prevent the word menu in the word window.
But the Winform's context menu can only be shown when the form is visible.
The information below is just for your information.
private void
wdApp_WindowBeforeRightClick(Microsoft.Office.Interop.Word.Selection Sel,
ref bool Cancel)
{
try
{
Debug.WriteLine("wdApp_WindowBeforeRightClick");
Form1 fm = new Form1();
fm.Show();
fm.ShowMenu(Cursor.Position);
// fm.Show();
// fm.Visible = false;
// fm.ContextMenu.Show(fm,Cursor.Position);
//fm.Close();
Cancel = true;
}
catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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