private void cEXWB1_NewWindow3(object sender, csExWB.NewWindow3EventArgs e) { try { e.Cancel = true; } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow3\r\n" + ee.ToString()); } }
void m_designer_HTMLEditDesigner_PreHandleEvent(object sender, csExWB.HTMLEditDesignerArgs e) { //Only events that are fired, minimal if (e.m_EventDispId == HTMLEventDispIds.ID_ONKEYDOWN) { if (e.m_pEvtObj != null) //65 A AllForms.m_frmLog.AppendToLog("ID_ONKEYDOWN_KeyCode ==>" + e.m_pEvtObj.keyCode.ToString()); } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONKEYUP) //never hits??? { if (e.m_pEvtObj != null) AllForms.m_frmLog.AppendToLog("ID_ONKEYUP_KeyCode ==>" + e.m_pEvtObj.keyCode.ToString()); } //else if (e.m_EventDispId == HTMLEventDispIds.ID_ONKEYPRESS) //{ // if (e.m_pEvtObj != null) //97 a // AllForms.m_frmLog.AppendToLog("ID_ONKEYPRESS_KeyCode ==>" + e.m_pEvtObj.keyCode.ToString()); //} else if (e.m_EventDispId == HTMLEventDispIds.ID_ONMOUSEDOWN) { if ((e.m_pEvtObj != null) && (e.m_pEvtObj.SrcElement != null)) AllForms.m_frmLog.AppendToLog("ID_ONMOUSEDOWN_TagName ==>" + e.m_pEvtObj.SrcElement.tagName); } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONMOUSEUP) { if ((e.m_pEvtObj != null) && (e.m_pEvtObj.SrcElement != null)) AllForms.m_frmLog.AppendToLog("ID_ONMOUSEUP_TagName ==>" + e.m_pEvtObj.SrcElement.tagName); } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONMOUSEOVER) { AllForms.m_frmLog.AppendToLog("ID_ONMOUSEOVER"); } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONMOUSEOUT) { AllForms.m_frmLog.AppendToLog("ID_ONMOUSEOUT"); } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONCONTEXTMENU) { AllForms.m_frmLog.AppendToLog("ID_ONCONTEXTMENU"); e.Cancel = true; } else if (e.m_EventDispId == HTMLEventDispIds.ID_ONMOUSEMOVE) { return; } else if (e.m_EventDispId == HTMLEventDispIds.ID_IME_EVENT) { AllForms.m_frmLog.AppendToLog("ID_IME_EVENT"); } else AllForms.m_frmLog.AppendToLog("m_EventDispId ==>" + e.m_EventDispId.ToString()); }
void cEXWB1_BeforeNavigate2(object sender, csExWB.BeforeNavigate2EventArgs e) { try { if(e.istoplevel) m_designer.DeactivateDesigner(); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog(this.Name + "_cEXWB1_DocumentComplete\r\n" + ee.ToString()); } }
private void cEXWB1_NewWindow2(object sender, csExWB.NewWindow2EventArgs e) { try { this.SetupNewForm(); newfrm.AssignBrowserObject(ref e.browser); //AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow2"); //e.Cancel = true; } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_NewWindow2\r\n" + ee.ToString()); } }
void cEXWB1_WBDragDrop(object sender, csExWB.WBDropEventArgs e) { if (e.dataobject.ContainsText()) AllForms.m_frmLog.AppendToLog("frmPopup_cEXWB1_WBDragDrop\r\n" + e.dataobject.GetText()); else if (e.dataobject.ContainsFileDropList()) { System.Collections.Specialized.StringCollection files = e.dataobject.GetFileDropList(); if (files.Count > 1) MessageBox.Show("Can not do multi file drop!"); else { this.cEXWB1.Navigate(files[0]); } } }
void cEXWB1_DocumentComplete(object sender, csExWB.DocumentCompleteEventArgs e) { try { if (e.istoplevel) { IHTMLDocument2 pDoc2 = ((IWebBrowser2)e.browser).Document as IHTMLDocument2; if (pDoc2 != null) { m_designer.ActivateDesigner(pDoc2); } } } catch (Exception ee) { AllForms.m_frmLog.AppendToLog(this.Name + "_cEXWB1_DocumentComplete\r\n" + ee.ToString()); } }
private static void DisposeCWB(csExWB.cEXWB c) { if (m_form.InvokeRequired) { log.Debug("Dispose CWB..."); m_form.BeginInvoke(new DisposeCWBDelegator(DisposeCWB), new object[] {c}); } else { try { c.Dispose(); } catch (Exception e) { log.Error(e); } } }
private static bool CWBLifeCheck(csExWB.cEXWB c) { if (m_CWBCOUNTDICT.ContainsKey(c)) { if (m_CWBCOUNTDICT[c] >= m_CWBLIFECOUNT) { m_CWBCOUNTDICT.Remove(c); return false; } else { m_CWBCOUNTDICT[c] = m_CWBCOUNTDICT[c] + 1; return true; } } else { log.Error("某浏览器对象的计数器元件未初始化!"); return false; } }
//Fired to indicate when download of a resource has failed void cEXWB1_ProtocolHandlerOperationFailed(object sender, csExWB.ProtocolHandlerOperationFailedEventArgs e) { Debug.Print(">>>>>>ProtocolHandlerOperationFailed=> " + e.URL); }
//Fired to indicate when a resource has been fully read by the MSHTML void cEXWB1_ProtocolHandlerDataFullyRead(object sender, csExWB.ProtocolHandlerDataFullyReadEventArgs e) { Debug.Print(">>>>>>ProtocolHandlerDataFullyRead=> " + e.URL); }
//Fired to indicate when a request for a resource is about to be initiated void cEXWB1_ProtocolHandlerBeginTransaction(object sender, csExWB.ProtocolHandlerBeginTransactionEventArgs e) { Debug.Print(">>>>>>ProtocolHandlerBeginTransaction=> " + e.URL); //+ "\r\nRequestHeaders >>\r\n" + e.RequestHeaders); }
void cEXWB1_BeforeNavigate2(object sender, csExWB.BeforeNavigate2EventArgs e) { Debug.Print(">>>>>>BeforeNavigate2=>" + e.url); }
private void cEXWB1_WBAuthenticate(object sender, csExWB.AuthenticateEventArgs e) { if (m_frmAuth.ShowDialogInternal(this) == DialogResult.OK) { //Default value of handled is false e.handled = true; //To pass a doamin as in a NTLM authentication scheme, //use this format: Username = Domain\username e.username = m_frmAuth.m_Username; e.password = m_frmAuth.m_Password; e.retvalue = 0; //Default value of retValue is 0 or S_OK } }
//A typical file attachment header from hotmail //HTTP/1.1 200 OK //Date: Mon, 20 Aug 2007 12:02:06 GMT //Server: Microsoft-IIS/6.0 //P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo" //xxn:18 //X-Powered-By: ASP.NET //Content-Length: 24955 //Content-Disposition: attachment; filename="TabStrip.zip" //MSNSERVER: H: BAY139-W18 V: 11.10.0.115 D: 2007-07-09T20:51:32 //Set-Cookie: KVC=11.10.0000.0115; domain=.mail.live.com; path=/ //Cache-Control: private //Content-Type: application/x-zip-compressed //http://data.unaids.org/pub/GlobalReport/2006/Annex2_Data_en.xls void cEXWB1_FileDownloadExStart(object sender, csExWB.FileDownloadExEventArgs e) { csExWB.cEXWB pWB = (csExWB.cEXWB)sender; try { MessageBox.Show(e.m_FileSize.ToString()); AllForms.m_frmLog.AppendToLog("cEXWB1_FileDownloadExStart\r\n" + e.m_URL + "\r\n" + e.m_Filename + "\r\n" + e.m_Ext + "\r\n" + e.m_FileSize + "\r\n" + e.m_ExtraHeaders); if (!string.IsNullOrEmpty(e.m_FileSize)) m_lFileSize = int.Parse(e.m_FileSize); else m_lFileSize = 0; //Send progress events. default false e.m_SendProgressEvents = true; //The initial value of FileDownloadDirectory defaults to MyDocuments dir e.m_PathToSave = pWB.FileDownloadDirectory + e.m_Filename; m_frmFileDownload.AddDownloadItem(pWB.Name, e.m_Filename, e.m_URL, e.m_dlUID, e.m_URL, e.m_PathToSave, m_lFileSize); if (!m_frmFileDownload.Visible) m_frmFileDownload.Show(this); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog(pWB.Name + "_FileDownloadExStart" + ee.ToString()); } }
void cEXWB1_FileDownloadExProgress(object sender, csExWB.FileDownloadExProgressEventArgs e) { MessageBox.Show(e.m_Progress.ToString()); csExWB.cEXWB pWB = (csExWB.cEXWB)sender; try { m_frmFileDownload.UpdateDownloadItem(pWB.Name, e.m_dlUID, e.m_URL, e.m_Progress, e.m_ProgressMax); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog(pWB.Name + "_FileDownloadExProgress" + ee.ToString()); } }
private void cEXWB1_StatusTextChange(object sender, csExWB.StatusTextChangeEventArgs e) { if (sender != m_CurWB) return; //if (e.text.Length > 0) m_Status = e.text; tsStatus.Text = e.text; }
private void cEXWB1_TitleChange(object sender, csExWB.TitleChangeEventArgs e) { if (sender != m_CurWB) return; this.Text = e.title; }
private void cEXWB1_NavigateComplete2(object sender, csExWB.NavigateComplete2EventArgs e) { }
private void cEXWB1_WBContextMenu(object sender, csExWB.ContextMenuEventArgs e) { try { if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_ANCHOR) { e.displaydefault = false; m_oHTMLCtxMenu = e.dispctxmenuobj; ctxMnuWB_A.Show(e.pt); } else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_IMAGE) { //If image has a HREF then enable CopyURLText image menu e.displaydefault = false; m_oHTMLCtxMenu = e.dispctxmenuobj; ctxMnuImgCopyUrlText.Enabled = false; IHTMLElement pelem = (IHTMLElement)m_oHTMLCtxMenu; if (pelem != null) { IHTMLElement pParent = pelem.parentElement; ctxMnuImgCopyUrlText.Enabled = (pParent.tagName.ToUpper() == "A") ? true : false; } ctxMnuImgOpenInBack.Enabled = ctxMnuImgCopyUrlText.Enabled; ctxMnuImgOpenInFront.Enabled = ctxMnuImgCopyUrlText.Enabled; ctxMnuWB_Img.Show(e.pt); } else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_CONTROL) { AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_CONTROL"); } else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_TEXTSELECT) { AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_TEXTSELECT"); } else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_TABLE) { AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_TABLE"); } AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_TAGNAME = " + e.ctxmenuelem.tagName); //else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_DEFAULT) //{ // AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_DEFAULT"); //} //else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_IMGART) //{ // AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_IMGART"); //} //else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_IMGDYNSRC) //{ // AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_IMGDYNSRC"); //} //else if (e.contextmenutype == WB_CONTEXTMENU_TYPES.CONTEXT_MENU_UNKNOWN) //{ // AllForms.m_frmLog.AppendToLog("CONTEXT_MENU_UNKNOWN"); //} } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("cEXWB1_WBContextMenu\r\n" + ee.ToString()); } }
//default, cancel = false; private void cEXWB1_NavigateError(object sender, csExWB.NavigateErrorEventArgs e) { //If using internal filedownlod mechanism, //we get nav errors for file download with status code 200(OK)???? if ((e.statuscode == WinInetErrors.HTTP_STATUS_OK) || (e.statuscode == WinInetErrors.HTTP_STATUS_CONTINUE) || (e.statuscode == WinInetErrors.HTTP_STATUS_REDIRECT) || //(e.statuscode == WinInetErrors.HTTP_STATUS_REQUEST_TIMEOUT) || (e.statuscode == WinInetErrors.HTTP_STATUS_ACCEPTED)) { return; //default handling } csExWB.cEXWB pWB = (csExWB.cEXWB)sender; //if (pWB != null) //{ // AllForms.m_frmLog.AppendToLog(pWB.Name + // "_NavigateError\r\nURL\r\n" + HttpUtility.UrlDecode(e.url) + // "\r\nStatus Code\r\n" + e.statuscode.ToString()); //} //else //{ // AllForms.m_frmLog.AppendToLog("cEXWBxx_NavigateError\r\nURL\r\n" + HttpUtility.UrlDecode(e.url) + // "\r\nStatus Code\r\n" + e.statuscode.ToString()); //} try { object nobj = null; //<HTML> tag is appended //Each line 200 chars string data = "about:<HEAD><title>Page Not Found</title></Head><Body><H3>Unable to load</H3><p>" + e.url + "<br>Reason:<br>" + e.statuscode.ToString() + "</p></Body>"; //No frames, main document //Do not set e.Cancel to true //as it stops the navigation of our main document //resulting in a blank page. Instead, we stop the navigation //and call our own navigate if (pWB.FramesCount() == 0) { //default //e.Cancel = false; pWB.Stop(); pWB.Navigate(data); return; } //If this is a Frame or IFrame then //we cancel the navigation to this page //and navigate to our error page. e.Cancel = true; //Variaty of ways to display an error page //Attempt to pass HTML directly to Navigate ((IWebBrowser2)e.browser).Navigate(data, ref nobj, ref nobj, ref nobj, ref nobj); //Attempt to nav to a page on a server //http://www.google.com //((IWebBrowser2)e.browser).Navigate("http://www.google.com", ref nobj, ref nobj, ref nobj, ref nobj); //Attempt to load a res file //res://exePath/#220 //Open up the compiled exe using VS and add resources! //Refer to this article for information //http://www.codeproject.com/csharp/embedwin32resources.asp //Display a blank page //about:blank //((IWebBrowser2)e.browser).Navigate("about:blank", ref nobj, ref nobj, ref nobj, ref nobj); //Attempt to load a local file //file:///E|//Test.htm - using this protocol in IE7 causes a //StackOverFlowException which means we don't have local file access } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("cEXWB1_NavigateError\r\n" + ee.ToString()); } }
//Fired to indicate when a frame or iframe document has unloaded void cEXWB1_WBSecondaryOnUnload(object sender, csExWB.SecondaryOnloadEventArgs e) { Debug.Print(">>>>>>WBSecondaryOnUnload=>" + e.WebBrowser.LocationURL); }
private void cEXWB1_NewWindow2(object sender, csExWB.NewWindow2EventArgs e) { //try //{ // string result = AllForms.m_frmDynamicConfirm.DisplayConfirm(this, // "A new window2 has been requested by " + m_CurWB.Name, // "Popup Window", // "Cancel popup", "Open in popup", "Open in new tab", string.Empty); // if (result == "Cancel popup") // e.Cancel = true; // else if (result == "Open in popup") // { // if (!m_frmPopup.Visible) // m_frmPopup.Show(this); // m_frmPopup.AssignBrowserObject(ref e.browser); // } // else if (result == "Open in new tab") // { // AddNewBrowser(m_Blank, m_AboutBlank, m_AboutBlank, true); // AssignPopup(ref e.browser); // } // //else open in current webbrowser //} //catch (Exception nEx) //{ // if (m_CurWB != null) // AllForms.m_frmLog.AppendToLog(m_CurWB.Name + "_NewWindow2\r\n" + nEx.ToString()); // else // AllForms.m_frmLog.AppendToLog("cEXWBxx_NewWindow2\r\n" + nEx.ToString()); //} //finally //{ //} }
void cEXWB1_DocumentComplete(object sender, csExWB.DocumentCompleteEventArgs e) { Debug.Print(">>>>>>DocumentComplete=>" + e.url); }
private void cEXWB1_NewWindow3(object sender, csExWB.NewWindow3EventArgs e) { try { string str = string.Empty; if (e.flags == NWMF.HTMLDIALOG) str = "HTML Dialog"; else if (e.flags == NWMF.SHOWHELP) str = "Show Help"; else str = e.flags.ToString(); string result = AllForms.m_frmDynamicConfirm.DisplayConfirm(this, "A new window3 has been requested by:\r\n" + e.url + "\r\nType:" + str, "Popup Window", "Cancel popup", "Open in popup", "Open in new tab", string.Empty); if (result == "Cancel popup") e.Cancel = true; else if (result == "Open in popup") { if (!m_frmPopup.Visible) m_frmPopup.Show(this); m_frmPopup.AssignBrowserObject(ref e.browser); } else if (result == "Open in new tab") { AddNewBrowser(m_Blank, m_AboutBlank, m_AboutBlank, true); AssignPopup(ref e.browser); } } catch (Exception nEx) { if (m_CurWB != null) AllForms.m_frmLog.AppendToLog(m_CurWB.Name + "_NewWindow3\r\n" + nEx.ToString()); else AllForms.m_frmLog.AppendToLog("cEXWBxx_NewWindow3\r\n" + nEx.ToString()); } finally { } }
//Fired to indicate when a resource has been fully downloaded and ready to be read by MSHTML void cEXWB1_ProtocolHandlerDataFullyAvailable(object sender, csExWB.ProtocolHandlerDataFullyAvailableEventArgs e) { Debug.Print(">>>>>>ProtocolHandlerDataFullyAvailable=> " + e.URL); }
private void cEXWB1_ProgressChange(object sender, csExWB.ProgressChangeEventArgs e) { if (sender != m_CurWB) return; try { if ((e.progress == -1) || (e.progressmax == e.progress)) { tsProgress.Value = 0; // 100; tsProgress.Maximum = 0; return; } if ((e.progressmax > 0) && (e.progress > 0) && (e.progress < e.progressmax)) { tsProgress.Maximum = e.progressmax; tsProgress.Value = e.progress; //* 100) / tsProgress.Maximum; } } catch (Exception) { } }
//Fired to indicate when a response from a server has been received void cEXWB1_ProtocolHandlerOnResponse(object sender, csExWB.ProtocolHandlerOnResponseEventArgs e) { Debug.Print(">>>>>>ProtocolHandlerOnResponse=> " + e.URL); //+ "\r\nResponseHeaders >>\r\n" + e.ResponseHeaders); }
private void cEXWB1_ScriptError(object sender, csExWB.ScriptErrorEventArgs e) { string wbname = (m_CurWB != null) ? m_CurWB.Name : "cEXWBxx"; e.continueScripts = true; AllForms.m_frmLog.AppendToLog(wbname + "_ScriptError - Continuing to run scripts"); AllForms.m_frmLog.AppendToLog("Error Message" + e.errorMessage + "\r\nLine Number" + e.lineNumber.ToString()); }
void cEXWB1_TitleChange(object sender, csExWB.TitleChangeEventArgs e) { this.Text = e.title; }
private void cEXWB1_SetSecureLockIcon(object sender, csExWB.SetSecureLockIconEventArgs e) { if (sender != m_CurWB) return; try { UpdateSecureLockIcon(e.securelockicon); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog(m_CurWB.Name + "_SetSecureLockIcon" + ee.ToString()); } }