/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; htmlDocument = (mshtml.HTMLDocument)webBrowserUserControl.Document.DomDocument; htmlBody = (mshtml.HTMLBody)htmlDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if (theIHTMLTxtRange.text == null) { } else { containsErrors = theIHTMLTxtRange.findText(ERROR, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if (theIHTMLTxtRange.text == null) { } else { containsWarnings = theIHTMLTxtRange.findText(WARNING, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } findRemainingText = htmlBody.createTextRange(); ((mshtml.IHTMLSelectionObject)htmlDocument.selection).empty(); }
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; if (_webBrowser.Document == null) { return; } _HTMLDocument = (mshtml.HTMLDocument)_webBrowser.Document.DomDocument; _HTMLBody = (mshtml.HTMLBody)_HTMLDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); if (theIHTMLTxtRange.text == null) { } else { _ContainsErrors = theIHTMLTxtRange.findText(_ERROR, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); } // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); if (theIHTMLTxtRange.text == null) { } else { _ContainsWarnings = theIHTMLTxtRange.findText(_WARNING, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); } _FindRemainingText = _HTMLBody.createTextRange(); ((mshtml.IHTMLSelectionObject)_HTMLDocument.selection).empty(); }
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; _HTMLDocument = (mshtml.HTMLDocument)_AxWebBrowser.Document; _HTMLBody = (mshtml.HTMLBody)_HTMLDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); _ContainsErrors = theIHTMLTxtRange.findText(_ERROR, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); _ContainsWarnings= theIHTMLTxtRange.findText(_WARNING, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); _FindRemainingText = _HTMLBody.createTextRange(); ((mshtml.IHTMLSelectionObject)_HTMLDocument.selection).empty(); }
/// <summary> /// Document complete method for the web browser /// Initiated by navigating to the about:blank page (EMPTY_PARAMETER HTML document) /// </summary> private void BrowserDocumentComplete(object sender, WebBrowserDocumentCompletedEventArgs e) { // get access to the HTMLDocument document = (mshtmlDocument)this.editorWebBrowser.Document.DomDocument; body = (mshtmlBody)document.body; // COM Interop Start // once browsing has completed there is the need to setup some options // need to ensure URLs are not modified when html is pasted IOleCommandTarget target = null; int hResult = HRESULT.S_OK; // try to obtain the command target for the web browser document try { // cast the document to a command target target = (IOleCommandTarget)document; // set the appropriate no url fixups on paste hResult = target.Exec(ref CommandGroup.CGID_MSHTML, (int)CommandId.IDM_NOFIXUPURLSONPASTE, (int)CommandOption.OLECMDEXECOPT_DONTPROMPTUSER, ref EMPTY_PARAMETER, ref EMPTY_PARAMETER); } // catch any exception and map back to the HRESULT catch (Exception ex) { hResult = Marshal.GetHRForException(ex); } // test the HRESULT for a valid operation if (hResult == HRESULT.S_OK) { // urls will not automatically be rebased rebaseUrlsNeeded = false; } else { //throw new HtmlEditorException(string.Format("Error executing NOFIXUPURLSONPASTE: Result {0}", hResult)); rebaseUrlsNeeded = true; } // COM Interop End // at this point the document and body has been loaded // so define the event handler for the context menu this.editorWebBrowser.Document.ContextMenuShowing += new HtmlElementEventHandler(DocumentContextMenu); this.editorWebBrowser.Document.AttachEventHandler("onselectionchange", DocumentSelectionChange); this.editorWebBrowser.Document.AttachEventHandler("onkeydown", DocumentKeyPress); // signalled complete codeNavigate = false; loading = false; // after navigation define the document Url string url = e.Url.ToString(); _bodyUrl = IsStringEqual(url, BLANK_HTML_PAGE) ? string.Empty : url; }
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; htmlDocument = (mshtml.HTMLDocument)webBrowserUserControl.Document.DomDocument; htmlBody = (mshtml.HTMLBody)htmlDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if(theIHTMLTxtRange.text == null) { } else { containsErrors = theIHTMLTxtRange.findText(ERROR, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } // Determine if warnings exist in the displayed Html. theIHTMLTxtRange = htmlBody.createTextRange(); if(theIHTMLTxtRange.text == null) { } else { containsWarnings= theIHTMLTxtRange.findText(WARNING, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD); } findRemainingText = htmlBody.createTextRange(); ((mshtml.IHTMLSelectionObject)htmlDocument.selection).empty(); }
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // get access to the HTMLDocument var htmlDocument = wb.Document; if (!htmlDocument.IsNull()) { document = (mshtmlDocument)htmlDocument.DomDocument; _doc = (mshtmlIHTMLDocument2)htmlDocument.DomDocument; // at this point the document and body has been loaded // so define the event handler for the context menu htmlDocument.ContextMenuShowing += DocumentContextMenu; //htmlDocument.AttachEventHandler("onselectionchange", DocumentSelectionChange); htmlDocument.AttachEventHandler("onkeydown", DocumentKeyDown); htmlDocument.AttachEventHandler("onkeyup", DocumentKeyUp); } body = (mshtmlBody)document.body; // COM Interop Start // once browsing has completed there is the need to setup some options // need to ensure URLs are not modified when html is pasted int hResult; // try to obtain the command target for the web browser document try { // cast the document to a command target var target = (IOleCommandTarget)document; // set the appropriate no url fixups on paste hResult = target.Exec(ref CommandGroup.CGID_MSHTML, (int)CommandId.IDM_NOFIXUPURLSONPASTE, (int)CommandOption.OLECMDEXECOPT_DONTPROMPTUSER, ref EMPTY_PARAMETER, ref EMPTY_PARAMETER); } // catch any exception and map back to the HRESULT catch (Exception ex) { hResult = Marshal.GetHRForException(ex); } // test the HRESULT for a valid operation rebaseUrlsNeeded = hResult != HRESULT.S_OK; // COM Interop End // signalled complete codeNavigate = false; loading = false; // after navigation define the document Url string url = e.Url.ToString(); _bodyUrl = IsStringEqual(url, BLANK_HTML_PAGE) ? string.Empty : url; }
private void WebDescriptionView_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { Cursor.Current = Cursors.Default; /* // update the URL displayed in the address bar String s = e.uRL.ToString(); // update the list of visited URLs int i = urlsVisited.IndexOf(s); if (i >= 0) currentUrlIndex = i; else currentUrlIndex = urlsVisited.Add(s); */ // get access to the HTMLDocument this.document = (HtmlDocument)this.WebDescriptionView.Document; this.document_body = (HtmlBody)document.body; // at this point the document and body has been loaded // so define the event handler as the same class ((mshtml.DispHTMLDocument)document).oncontextmenu = this; ((mshtml.DispHTMLDocument)document).onkeypress = this; ((mshtml.DispHTMLDocument)document).onkeydown = this; ((mshtml.DispHTMLDocument)document).onkeyup = this; /* // Update the context sensitive menu for the browser this.CM_Back.Enabled = this.can_navigate_back; this.CM_Forward.Enabled = this.can_navigate_forward; */ //this.CM_FindAgain.Enabled = (((MainForm)this.ParentForm).search_string != ""); // the search options value '6' maps to: 'match case' & 'match whole words'. this.FindReset(); this._contains_errors = this.find_range.findText ("Error:", this.find_range.text.Length, 6); this.FindReset(); this._contains_warnings = this.find_range.findText ("Warning:", this.find_range.text.Length, 6); this.FindReset(); // Update the controls of the mainform (toolbar, menubar, title bar) ((MainForm)this.ParentForm).UpdateUIControls (); }