Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Bjarni_Fridjonsson

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.

  [Flags]

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_OnContextMenu);

           

this.axQlikMainApp.OnContextMenuCommand += new AxQlikOCXLib._DQlikOCXEvents_OnContextMenuCommandEventHandler

     (this.axQlikMainApp_OnContextMenuCommand);

//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");

}

0 Replies