0 Replies Latest reply: Mar 15, 2013 10:17 AM by Bjarni Fridjonsson RSS

    How to add to a Right-Click Menu Item in the OCX

      Adding a MenuItem to the right click context menu of a object in QlikView is not documented.


      and you can cancel the contextMenu action by setting e.okToContinue =0


      c# code.



      public enum MenuFlags : uint


           MF_STRING = 0,

           MF_BYPOSITION = 0x400,

           MF_SEPARATOR = 0x800,

           MF_REMOVE = 0x1000,



      [DllImport("user32.dll", CharSet = CharSet.Auto)]

      static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);


      'add this to after your InitializeComponent in your form or use the event properties in the designer.           

      this.axQlikMainApp.OnContextMenu += new AxQlikOCXLib._DQlikOCXEvents_OnContextMenuEventHandler



      this.axQlikMainApp.OnContextMenuCommand += new AxQlikOCXLib._DQlikOCXEvents_OnContextMenuCommandEventHandler



      //Here we are adding to the menu.

      private void axQlikMainApp_OnContextMenu(object sender, AxQlikOCXLib._DQlikOCXEvents_OnContextMenuEvent e)


           var x = new IntPtr(e.contextMenu);

              AppendMenu(x, MenuFlags.MF_STRING, 2, "This is a new menu");



      //This is the event that is raised by all of the commands.

      private void axQlikMainApp_OnContextMenuCommand(object sender, AxQlikOCXLib._DQlikOCXEvents_OnContextMenuCommandEvent e)


          if(e.menuCommand == 8000)

              MessageBox.Show("New menu clicked");