void CustomContextMenuManager_ShowContextMenu(object sender, ShowContextMenuEventArgs e) { if (!webKitBrowser1.UseDefaultContextMenu) { ContextMenu tst = new ContextMenu(); MenuItem mn = new MenuItem("Test1"); tst.MenuItems.Add(mn); MenuItem mn2 = new MenuItem("Test2"); tst.MenuItems.Add(mn2); MenuItem mn3 = new MenuItem("-"); tst.MenuItems.Add(mn3); MenuItem mn4 = new MenuItem("Test3"); tst.MenuItems.Add(mn4); tst.Show(webKitBrowser1, e.Location); } }
public int ShowContextMenu(int dwID, ref Interop.POINT pt, object pcmdtReserved, object pdispReserved) { Point location = htmlEditor.PointToClient(new Point(pt.x, pt.y)); Interop.IHTMLElement element = this.MSHTMLDocument.ElementFromPoint(location.X, location.Y); Control ielement = this.htmlEditor.GenericElementFactory.CreateElement(element); ShowContextMenuEventArgs e = new ShowContextMenuEventArgs(location, false, dwID, ielement); try { htmlEditor.OnShowContextMenu(e); } catch { // Make sure we return Interop.S_OK } return(Interop.S_OK); }
private void OnShowContextMenu(object sender, ShowContextMenuEventArgs e) { if (MenuCommandService != null) { OnBeforeShowContextMenu(); var explorerContextMenu = GetContextMenuCommandID(); var p = _elementHost.PointToScreen(new Point((int)e.Point.X, (int)e.Point.Y)); try { MenuCommandService.ShowContextMenu(explorerContextMenu, p.X, p.Y); } catch (COMException ex) { // do not rethrow exception as this causes VS crash Debug.Fail("Caught exception of type " + ex.GetType().FullName + " with message " + ex.Message + ". Stack Trace: " + ex.StackTrace); } } }
protected virtual void OnShowContextMenu(ShowContextMenuEventArgs e) { var handler = ShowContextMenu; if (handler != null) { handler(e); if (e.ContextMenuToShow != null) { ContextMenuStrip toolStrip = (ContextMenuStrip)Control.FromHandle(Handle); Point client = toolStrip.PointToClient(Control.MousePosition); SourceItem = toolStrip.GetItemAt(client); previousItemBackColor = SourceItem.BackColor; SourceItem.BackColor = SystemColors.MenuHighlight; e.ContextMenuToShow.Closed -= restoreItemState; e.ContextMenuToShow.Closed += restoreItemState; keepOpen = true; e.ContextMenuToShow.Show(Control.MousePosition); keepOpen = false; } } }
protected virtual void RaiseShowContextMenuEvent() { // Raise event if (null != ShowContextMenu) { // Populate event args ShowContextMenuEventArgs e = new ShowContextMenuEventArgs(); e.MousePos = MousePos; if (MySelectedIndex >= 0) { e.SelectedRecord = MyLayout[MySelectedIndex].Record; e.SelectedFrame = MyLayout[MySelectedIndex].Frame; } else { e.SelectedRecord = -1; e.SelectedFrame = -1; } // Raise event ShowContextMenu(this, e); } }