unsafe HRESULT IDocHostUIHandler.ShowContextMenu(uint dwID, Point *pt, object pcmdtReserved, object pdispReserved) { WebBrowser wb = (WebBrowser)Host; if (wb.IsWebBrowserContextMenuEnabled) { // let MSHTML display its UI return(HRESULT.S_FALSE); } if (pt is null) { return(HRESULT.E_INVALIDARG); } if (pt->X == 0 && pt->Y == 0) { // IDocHostUIHandler::ShowContextMenu sends (0,0) when the context menu is invoked via the keyboard // make it (-1, -1) for the WebBrowser::ShowContextMenu method pt->X = -1; pt->Y = -1; } wb.ShowContextMenu(*pt); // MSHTML should not display its context menu because we displayed ours return(HRESULT.S_OK); }
int System.Windows.Forms.UnsafeNativeMethods.IDocHostUIHandler.ShowContextMenu(int dwID, System.Windows.Forms.NativeMethods.POINT pt, object pcmdtReserved, object pdispReserved) { WebBrowser host = (WebBrowser)base.Host; if (host.IsWebBrowserContextMenuEnabled) { return(1); } if ((pt.x == 0) && (pt.y == 0)) { pt.x = -1; pt.y = -1; } host.ShowContextMenu(pt.x, pt.y); return(0); }