Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am using the Microsoft Ax Framer Control to view the word document in the Visual C# Form.

After Hosting(Open) the Word Document in the Ax Framer Control.

While Right Click on the Word Document, Ms word Context Menu is Appearing.

I Want to Hide this Pop up Menu.

I set
Word.Document wddoc = (Word.Document)axFramerControl1.ActiveDocument;
Word.Application wordApp = wddoc.Application;
wordApp.WindowBeforeRightClick += new ApplicationEvents4_WindowBeforeRightClickEventHandler(wordApp_WindowBeforeRightClick);

to handle RightClick. But The application doesn't run
wordApp_WindowBeforeRightClick
event.
What's the problem?

C#
void wordApp_WindowBeforeRightClick(Selection Sel, ref bool Cancel)
        {           
            Cancel = true;
            AddContextMenu();
        }

        private void AddContextMenu()
        {
            Word.Document wddoc = (Word.Document)axFramerControl1.ActiveDocument;
            Word.Application wordApp = wddoc.Application;
            
            Office.CommandBar ContextMenu = wordApp.CommandBars.Add("ContextMenu",         
            Office.MsoBarPosition.msoBarPopup, Type.Missing, true);

            if (ContextMenu != null)
            {
                Office.CommandBarPopup cpp =
                              (Office.CommandBarPopup)ContextMenu.Controls.Add
                              (Office.MsoControlType.msoControlPopup,Type.Missing, Type.Missing, 
                              Type.Missing, Type.Missing);
                cpp.Caption = "SubMenu";

                Office.CommandBarButton cbHello1 = 
                     (Office.CommandBarButton)cpp.Controls.Add
                     (Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing,     
                     Type.Missing, Type.Missing);
                cbHello1.Caption = "Hello1";              

                ContextMenu.ShowPopup(Type.Missing, Type.Missing);
            }
        }
Posted
Updated 29-Jun-14 0:16am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900