Friday, August 5, 2011

Find Element name on MouseDown IE-8

Yesterday I was working on click even of WebBrowser Control(HtmlDocument). I need to find element name on mouse down event. I have used simple method of WebBrowser

HtmlElement objHtmElem = objWebBrwser.Document.GetElementFromPoint(e.MousePosition);

It was working fine in IE-5. But when I have installed IE-8. All the functionality has been disturbed. On mouse down it was giving Document Element name no matter matter where you have down your mouse.

After lot of googling I have solved the problem. Actually where we have used e.MousePosition we must use e.ClientMousePostion like..

HtmlElement objHtmElem = objWebBrwser.Document.GetElementFromPoint(e.ClientMousePosition);

This works fine for both browser(IE-5 and IE-8).

No comments: