765

WebBrowser control capture DHTML (mouse) events disables browser

Am o problema, sa fiu sincer deja de o zi ma chinui si nu pot rezolva, am gasit pe forumuri acelasi bug la IE, dar nu pot gasi solutia nimic nu merge din ceea ce spun, fac un copy paste de la un ciuvak care cred ca o descris mai bine. Cine stie pls help. multumesc.I'm trying to capture the mouse click events in the WebBrowser control, such as onmouseup, onmousedown, and oncontextmenu, that is only offered through using the mshtml library (DHTML objects). The instructions from Microsoft are simple (http://support.microsoft.com/?kbid=312777), and the code I'm using is below. The control is hosted on a Win Form using C#.What happens is, if I add an event handler for ANY of these types of events, the browser becomes completely disabled. I am unable to select text or click on html links to go to another page. Even if I just add one event handler for oncontextmenu for example, the same thing happens. It breaks the browser and there is no obvious reason that I can figure out. I tried to make sure the cancelBubble property is set to false but it doesn't make a difference.Is there a problem with my code or approach, or is there a better way to accomplish this that I should be doing instead. I want to be able to sense when a user has selected text on a web page, as well as clicks on images. So I need to be able to capture mouse events and selection events, but also be able to ignore them and have the browser work as expected.private void browser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e){ mshtml.HTMLDocument doc; doc = (mshtml.HTMLDocument)this.browser.Document; mshtml.HTMLDocumentEvents2_Event iEvent; iEvent = (mshtml.HTMLDocumentEvents2_Event) doc; iEvent.oncontextmenu += new mshtml.HTMLDocumentEvents2_oncontextmenuEventHandler(OnBrowserEvent_ContextMenu); iEvent.onmousedown +=new mshtml.HTMLDocumentEvents2_onmousedownEventHandler(iEvent_onmousedown); iEvent.onmouseup +=new mshtml.HTMLDocumentEvents2_onmouseupEventHandler(iEvent_onmouseup);}private bool OnBrowserEvent_ContextMenu(mshtml.IHTMLEventObj e){ //Don't show the default context menu - TODO return false;}private void iEvent_onmousedown(mshtml.IHTMLEventObj pEvtObj){ //Do something}private void iEvent_onmouseup(mshtml.IHTMLEventObj pEvtObj){ //Do something}
0