// Event を関連付けるテスト private void WebBrowser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { mshtml.HTMLDocumentEvents2_Event iEvent = (mshtml.HTMLDocumentEvents2_Event) this.document; iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler); //iEvent.onmouseover+=new mshtml.HTMLDocumentEvents2_onmouseoverEventHandler(MouseOverEventHandler); Console.WriteLine("hooked"); }
void VisualizeCallback(object sender, EventArgs e) { //here we need to open the xml file //we can either open it using a system command (open a webpage) //or we can open it in visual studio //2. figure out how to open via normal web browser // easy, just call start process try { if (CodeCommandsUnavailable()) { throw new Exception(); } string filename = ""; if (IsGeneratedFileAvailable(".xml", ref filename)) { string url = "file://" + filename; //before navigating, apparently you have to do this. CoInternetSetFeatureEnabled(INTERNETFEATURELIST.FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, false); Window window = App().ItemOperations.Navigate(url, vsNavigateOptions.vsNavigateOptionsDefault); window.Caption = "opC++ Visualization"; SHDocVw.WebBrowser browser = window.Object as SHDocVw.WebBrowser; if (browser != null) { mshtml.HTMLDocument doc = browser.Document as mshtml.HTMLDocument; mshtml.HTMLDocumentEvents2_Event ievent = doc as mshtml.HTMLDocumentEvents2_Event; //NOTE: theres some issue with this // it seems to work the first time but doesn't after that // I suspect this could be a garbage collection issue. if (ievent != null) { ievent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickVisualize); } } return; } } catch (Exception) { } //Now we can add our event handler //m_hostedBrowser.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(NavigateComplete2); }